How do I enable statistics with Hibernate and JPA?

You can enable Hibernate statistics by setting the property hibernate.generate_statistics in the persistence.xml of your application: <property name=”hibernate.generate_statistics”>true</property> For Hibernate native application, you need to include the above property in hibernate.cfg.xml After deploying the application, you will see in your server logs the following statistics when the Hibernate session is closed: 18:16:30,502 INFO [org.hibernate.engine.internal.StatisticalLoggingSessionEventListener] (default … Read more

Hibernate fetching performance tuning

Joining tables in SQL is the foundation of a relational database, as joins allow you to actually model relationships between tables. In plain JDBC, joins between tables are composed using native SQL statements. On the other hand, when using Hibernate/JPA this is greatly simplified as you will specify the relation between tables in terms of … Read more