Hibernate可以生成大写的SQL吗?即一些可以发送的选项
SELECT table1_.prop1_ FROM my_table AS table1_;
而不是当前
select table1_.prop1_ from my_table as table1_;
我认为它的可读性要差得多,尤其是。对于长查询,HBN 倾向于吐出。另见https://forum.hibernate.org/viewtopic.php?f=1&t=932412
谢谢
我不知道只有开箱即用才能将关键字大写的方法。但是您可以编写自己的拦截器并实现o.h.Interceptor#onPrepareStatement(String)
以根据需要转换 sql 字符串。
I don't know that this will enforce uppercase, but it does help with readability. In your hibernate.cfg.xml place the following in your <session-factory>
element:
<!--hibernate.cfg.xml -->
<property name="format_sql">true</property>
发现:Hibernate 团队之王严格反对这样的选择:
http://opensource.atlassian.com/projects/hibernate/browse/HB-1070
对于任何寻找此内容的人,请在此处发表评论(您不能对已关闭的问题进行投票:()
更新:另一个解决方案是替换 hibernate 的 .jar 中的 FreeMarker 模板。