开发者

How to Make Hibernate Print Out IDs in the Console?

I'm using Hibernate/Spring. I have Hibernate configured to output HQL into the Console; it shows things like:

Hibernate: update sometable set some_field=?, other_field=? where id=?

This is great. The only additional thing I want is to replace the question-marks with REAL IDs.

The context is that I'm trying to investigate if a cascading delete is responsible for deleting a record after the parent/ow开发者_如何学Cner of that record is changed (say, from P1 to P2) and then the old parent P1 is deleted.


You need to enable (log4j) logging for this packages and this level:

org.hibernate.sql=TRACE
org.hibernate.type=TRACE

It should produce trace messages about each parameter.

@see thierd replaiy for an example

added

Only a hint: because it would be useless if the statements and parameters are shown/logged to different places:

Instead of using "hibernate.show_sql" you can enable DEBUG logging for "org.hibernate.SQL". Now you should see the SQL logged in your Log4J output rather than in the console.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜