High-Performance Java Persistence – Chapter 9 – Hibernate Connection Management

Part 2, Chapter 9

Every new chapter of my book is released right after it’s being completed, so the reader doesn’t have to wait for the whole part to be finished to get access to new material.

Table of content

This chapter explains how to handle connections in Hibernate and how to monitor their usage as well as the statement that get automatically generated, and the table of content looks like this:

9. Connection Management and Monitoring
9.1 JPA connection management
9.2 Hibernate connection providers 
9.2.1 DriverManagerConnectionProvider
9.2.2 C3P0ConnectionProvider 
9.2.3 HikariConnectionProvider 
9.2.4 DatasourceConnectionProvider 
9.2.5 Connection release modes 
9.3 Monitoring connections 
9.3.1 Hibernate statistics 
9.3.1.1 Customizing statistics 
9.4 Statement logging
9.4.1 Statement formatting 
9.4.2 Statement-level comments 
9.4.3 Logging parameters 
9.4.3.1 DataSource-proxy 
9.4.3.2 P6Spy

Chapter summary

The connection provider has a very serious impact on the overall application performance, so this chapter goes through the most common ConnectionProvider implementations and explains which are the most suitable for a high-performance OLTP system.

Hibernate has many subtleties, and one of the least known connection-related configuration option is the JTA release mode.
In this chapter, I will explain when it’s safe to override the default after_statement release mode and how much performance does it buy you.

Monitoring connections and transactions are mandatory in any enterprise system. Hibernate comes with its own statistics collector, providing an extension point mechanism to listen to Hibernate internal events. Int this chapter, I explain how you can customize the default mechanism and implement a transaction tracking statistics mechanism.

Last but not least, statement logging has its quirks as well. For this reason, I explained which configuration properties propagate to the underlying Driver or to the currently configured Logger and how to print PreparedStatement bind parameter values. This chapter was the right place to introduce two very useful JDBC proxying frameworks: datasource-proxy and P6Spy, each one offering more than just statement logging.

Enjoy reading it and I am looking forward to getting your feedback.

If you liked this article, you might want to subscribe to my newsletter too.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s