Hibernate Advanced Concepts

Hibernate Persistence Class
– This is the Class that represents a Database table. What is required of this Class are the corresponding fields, its Setters and Getters, and a Constructor. Other properties of this table are defined in the *.hbm.xml file.

Hibernate Session
– The Session is the Object used for the database transactions. This is where we can set all our SQL ( or in this case HQL / Hibernate Query Language ) and the Persistence class for Database Transaction. It is advised only create and open a session if needed, and close it after the transaction. The Session Factory is Thread Safe, but Sessions are not.

Hibernate Batch Processing
– Hibernate allows batch processing. To do this, the session must be flush() and clear() in a certain point of the iteration, before doing transaction commit.

also another tip is to set these properties. It sort the inserts and updates, for better performance.

<prop key=”hibernate.order_inserts”>true</prop>
<prop key=”hibernate.order_updates”>true</prop>

Below are some good tips on how to do a Batch process:

Hibernate Caching
– Hibernate operates with a default first level cache, and a option to activate the secondary cache, and even additional caches from a 3rd party is permitted.

Hibernate Interceptors
– Interceptors are functions in hibernate that can do process during the time a session is doing transaction in the cache and in the database. Interceptors can cut in inside the steps of this process.

One thought on “Hibernate Advanced Concepts

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