hibernate.format_sql = true
如果想要仔细看Hibernate生成的SQL语句,将format_sql设为true可以很大程度地减轻痛苦……
再加上这个的话:
hibernate.use_sql_comments = true
个人认为 [可读性 + 可定位性] 会更好。
当然,这两个一起来的话也会造成SQL在console中显示的篇幅很大。例如:
如果想要仔细看Hibernate生成的SQL语句,将format_sql设为true可以很大程度地减轻痛苦……
再加上这个的话:
hibernate.use_sql_comments = true
个人认为 [可读性 + 可定位性] 会更好。
当然,这两个一起来的话也会造成SQL在console中显示的篇幅很大。例如:
- /**
- * 以下是Hibernate在控制台中自动生成的log
- */
- Hibernate:
- /* criteria query */ select
- this_.id as id88_0_,
- this_.flag as flag88_0_,
- this_.description as descript3_88_0_,
- this_.mobilizationDate as mobiliza4_88_0_,
- this_.recordId as recordId88_0_,
- this_.deptFromId as deptFromId88_0_,
- this_.deptToId as deptToId88_0_
- from
- Mobilization this_
- where
- this_.flag=?
- order by
- this_.id asc
- Hibernate:
- /* load net.example.model.PersonnelRecord */ select
- personnelr0_.id as id91_0_,
- personnelr0_.flag as flag91_0_,
- personnelr0_.birthDate as birthDate91_0_,
- personnelr0_.deptId as deptId91_0_,
- personnelr0_.eduQualificationId as eduQuali5_91_0_,
- personnelr0_.firstWorkDate as firstWor6_91_0_,
- personnelr0_.gender as gender91_0_,
- personnelr0_.idNumber as idNumber91_0_,
- personnelr0_.nationalityId as national9_91_0_,
- personnelr0_.originDate as originDate91_0_,
- personnelr0_.politicalConditionId as politic11_91_0_,
- personnelr0_.socialRelation as socialR12_91_0_,
- personnelr0_.description as descrip13_91_0_,
- personnelr0_.jobPositionId as jobPosi14_91_0_,
- personnelr0_.jobTitleId as jobTitleId91_0_,
- personnelr0_.jobTypeId as jobTypeId91_0_,
- personnelr0_.personName as personName91_0_,
- personnelr0_.iconUrl as iconUrl91_0_,
- personnelr0_.officialFlagId as officia19_91_0_,
- personnelr0_.marriageFlagId as marriag20_91_0_,
- personnelr0_.personnelNumber as personn21_91_0_,
- personnelr0_.quitWorkDate as quitWor22_91_0_,
- personnelr0_.address as address91_0_,
- personnelr0_.cellPhoneNumber as cellPho24_91_0_,
- personnelr0_.email as email91_0_,
- personnelr0_.phoneNumber as phoneNu26_91_0_,
- personnelr0_.nativeLocation as nativeL27_91_0_
- from
- PersonnelRecord personnelr0_
- where
- personnelr0_.id=?
- Hibernate:
- /* load net.example.model.Department */ select
- department0_.id as id81_0_,
- department0_.flag as flag81_0_,
- department0_.deptName as deptName81_0_,
- department0_.deptTypeId as deptTypeId81_0_,
- department0_.description as descript5_81_0_,
- department0_.deptNumber as deptNumber81_0_
- from
- Department department0_
- where
- department0_.id=?
- Hibernate:
- /* load net.example.model.Department */ select
- department0_.id as id81_0_,
- department0_.flag as flag81_0_,
- department0_.deptName as deptName81_0_,
- department0_.deptTypeId as deptTypeId81_0_,
- department0_.description as descript5_81_0_,
- department0_.deptNumber as deptNumber81_0_
- from
- Department department0_
- where
- department0_.id=?