2

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?

1 Answer 1

4

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.