开发者

Can Hibernate generate uppercase SQL?

can Hibernate generate uppercase SQL? I.开发者_高级运维e. some option which would make it send

SELECT table1_.prop1_ FROM my_table AS table1_;

instead of current

select table1_.prop1_ from my_table as table1_;

which I consider far less readable, esp. for long queries HBN tends to spit. See also https://forum.hibernate.org/viewtopic.php?f=1&t=932412

Thanks


I'm not aware of a way to upper case the keywords only out-of-the-box. But you could write your own interceptor and implement o.h.Interceptor#onPrepareStatement(String) to transform the sql string as you like.


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>


Found: The King of the Hibernate team is strictly against such option:

http://opensource.atlassian.com/projects/hibernate/browse/HB-1070

For anyone looking for this, please comment there (you can't vote on closed issues :( )

Update: Another solution is to replace the FreeMarker templates in hibernate's .jar's.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜