Hibernate打印SQL及附加参数
时间:2021-07-01 10:21:17
帮助过:35人阅读
/* load collection cc.unmi.test.model.Post.categories */ select
categories0_.post_id as post1_7_1_,
elementite1_.id as id3_0_,
from
Post_Category_Relationship categories0_
inner join
unmi.element_item elementite1_
on categories0_.category_id=elementite1_.id
where
categories0_.post_id=?
20:13:40.710 [http-8080-1] TRACE org.hibernate.type.descriptor.sql.BasicBinder - binding parameter [1] as [INTEGER] - 10
20:13:40.710 [http-8080-1] TRACE org.hibernate.type.descriptor.sql.BasicExtractor - found [1002] as column [id3_0_]
20:13:40.710 [http-8080-1] TRACE org.hibernate.type.descriptor.sql.BasicExtractor - found [10] as column [post1_7_1_]
如果还想查看查询中命名参数的值,还需要在log4j的配置文件中加上如下的值:
log4j.logger.org.hibernate.engine.QueryParameters=DEBUG
log4j.logger.org.hibernate.engine.query.HQLQueryPlan=DEBUG
这样修改之后,可以得到如下的结果:
Console代码
- 20:13:40.710 [http-8080-1] org.hibernate.engine.query.HQLQueryPlan - find: from User where email = :email
- 20:13:40.710 [http-8080-1] org.hibernate.engine.QueryParameters - named parameters: {email=fantasia@sina.com}
- 20:13:40.726 [http-8080-1] org.hibernate.SQL -
- /* named HQL query findUserByEmail */ select
- user0_.id as id0_,
- user0_.email as email0_,
- user0_.enabled as enabled0_,
- user0_.encodedPassword as encodedP8_0_
- from
- User user0_
- where
- user0_.email=?
Hibernate打印SQL及附加参数
标签:uri 指示 sql 语句 icon mat 查看 span ons