Reputation: 4608
I am trying to see the sql queries that are executed by hibernate, so I have:
AnnotationConfiguration hibernateConfig = new AnnotationConfiguration();
...//configuring the data url, user, etc.
hibernateConfig.setProperty("show_sql", "true");
hibernateConfig.setProperty("format_sql", "true");
It is hard to find the correct property names, so I used the same name as I would use in the xml file, but I don't find any outputs to the log.
Is it anything else that I need to do, besides adding the above two lines?
Upvotes: 1
Views: 1224
Reputation: 19956
You need to prefix property names with hibernate
hibernateConfig.setProperty("hibernate.show_sql", "true");
hibernateConfig.setProperty("hibernate.format_sql", "true");
hibernateConfig.setProperty("hibernate.use_sql_comments", "true");
The property hibernate.use_sql_comments
to show corresponding HQL
And you can set this properties in the hibernate.properties
of course
hibernate.show_sql=true
hibernate.use_sql_comments=true
hibernate.use_sql_comments=true
Upvotes: 3