前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >日志中输出 Hibernate HQL 中的参数

日志中输出 Hibernate HQL 中的参数

作者头像
前Thoughtworks-杨焱
发布2022-02-19 10:31:41
8330
发布2022-02-19 10:31:41
举报
文章被收录于专栏:杨焱的专栏

发表于2018-05-262019-01-01 作者 wind

需要设置 hibernate 的日志的实现,我这里用slf4j:

代码语言:javascript
复制
public static void main(String[] args) {
    System.setProperty("jboss.logging.provider", "slf4j");
    SpringApplicationBuilder builder = new SpringApplicationBuilder().web(true).sources(Application.class).profiles(
        "web");
    builder.run(args);
}

我用的是spring boot项目结构,所以在application.yml里面直接配置日志:

代码语言:javascript
复制
logging:
  level:
    root: info
    org.hibernate.hql.internal.ast.HqlSqlWalker: error
    org.hibernate.type.descriptor.sql.BasicBinder: trace
#    org.hibernate.type.descriptor.sql.BasicExtractor: trace
    org.hibernate.engine.spi.QueryParameters: trace
#    org.hibernate.engine.query.spi.HQLQueryPlan: trace
    cn.firegod: debug

这样在执行的时候,就会有类似下面这样的输出:

代码语言:javascript
复制
Hibernate: select courseenti0_.id as id1_15_0_, courseenti0_.create_by as create_b2_15_0_, courseenti0_.create_date as create_d3_15_0_, courseenti0_.del_flag as del_flag4_15_0_, courseenti0_.name as name5_15_0_, courseenti0_.remarks as remarks6_15_0_, courseenti0_.update_by as update_b7_15_0_, courseenti0_.update_date as update_d8_15_0_ from cdev_school_course courseenti0_ where courseenti0_.id=?
2018-05-26 13:40:40.523 TRACE 64785 --- [nio-9999-exec-2] o.h.type.descriptor.sql.BasicBinder      : binding parameter [1] as [INTEGER] - [1]
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2018-05-26,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档