hibernate.use_sql_comments作用

  hibernate.format_sql = true

如果想要仔细看Hibernate生成的SQL语句,将format_sql设为true可以很大程度地减轻痛苦……


再加上这个的话:
hibernate.use_sql_comments = true

个人认为 [可读性 + 可定位性] 会更好。

当然,这两个一起来的话也会造成SQL在console中显示的篇幅很大。例如:

Java代码 复制代码  收藏代码
  1. /**  
  2.  * 以下是Hibernate在控制台中自动生成的log  
  3.  */  
  4.   
  5. Hibernate:   
  6.     /* criteria query */ select   
  7.         this_.id as id88_0_,   
  8.         this_.flag as flag88_0_,   
  9.         this_.description as descript3_88_0_,   
  10.         this_.mobilizationDate as mobiliza4_88_0_,   
  11.         this_.recordId as recordId88_0_,   
  12.         this_.deptFromId as deptFromId88_0_,   
  13.         this_.deptToId as deptToId88_0_   
  14.     from   
  15.         Mobilization this_   
  16.     where   
  17.         this_.flag=?   
  18.     order by   
  19.         this_.id asc   
  20.   
  21. Hibernate:   
  22.     /* load net.example.model.PersonnelRecord */ select   
  23.         personnelr0_.id as id91_0_,   
  24.         personnelr0_.flag as flag91_0_,   
  25.         personnelr0_.birthDate as birthDate91_0_,   
  26.         personnelr0_.deptId as deptId91_0_,   
  27.         personnelr0_.eduQualificationId as eduQuali5_91_0_,   
  28.         personnelr0_.firstWorkDate as firstWor6_91_0_,   
  29.         personnelr0_.gender as gender91_0_,   
  30.         personnelr0_.idNumber as idNumber91_0_,   
  31.         personnelr0_.nationalityId as national9_91_0_,   
  32.         personnelr0_.originDate as originDate91_0_,   
  33.         personnelr0_.politicalConditionId as politic11_91_0_,   
  34.         personnelr0_.socialRelation as socialR12_91_0_,   
  35.         personnelr0_.description as descrip13_91_0_,   
  36.         personnelr0_.jobPositionId as jobPosi14_91_0_,   
  37.         personnelr0_.jobTitleId as jobTitleId91_0_,   
  38.         personnelr0_.jobTypeId as jobTypeId91_0_,   
  39.         personnelr0_.personName as personName91_0_,   
  40.         personnelr0_.iconUrl as iconUrl91_0_,   
  41.         personnelr0_.officialFlagId as officia19_91_0_,   
  42.         personnelr0_.marriageFlagId as marriag20_91_0_,   
  43.         personnelr0_.personnelNumber as personn21_91_0_,   
  44.         personnelr0_.quitWorkDate as quitWor22_91_0_,   
  45.         personnelr0_.address as address91_0_,   
  46.         personnelr0_.cellPhoneNumber as cellPho24_91_0_,   
  47.         personnelr0_.email as email91_0_,   
  48.         personnelr0_.phoneNumber as phoneNu26_91_0_,   
  49.         personnelr0_.nativeLocation as nativeL27_91_0_   
  50.     from   
  51.         PersonnelRecord personnelr0_   
  52.     where   
  53.         personnelr0_.id=?   
  54.   
  55. Hibernate:   
  56.     /* load net.example.model.Department */ select   
  57.         department0_.id as id81_0_,   
  58.         department0_.flag as flag81_0_,   
  59.         department0_.deptName as deptName81_0_,   
  60.         department0_.deptTypeId as deptTypeId81_0_,   
  61.         department0_.description as descript5_81_0_,   
  62.         department0_.deptNumber as deptNumber81_0_   
  63.     from   
  64.         Department department0_   
  65.     where   
  66.         department0_.id=?   
  67.   
  68. Hibernate:   
  69.     /* load net.example.model.Department */ select   
  70.         department0_.id as id81_0_,   
  71.         department0_.flag as flag81_0_,   
  72.         department0_.deptName as deptName81_0_,   
  73.         department0_.deptTypeId as deptTypeId81_0_,   
  74.         department0_.description as descript5_81_0_,   
  75.         department0_.deptNumber as deptNumber81_0_   
  76.     from   
  77.         Department department0_   
  78.     where   
  79.         department0_.id=?  
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值