Bidirectional Many-To-One/One-To-Many Relationship in Hibernate

In bidirectional association, we will have navigations in both direction, i.e, both side of the association will have the reference to the other side. The both side of the association will implement one of the collection interfaces, if it has the reference to the other entity.

In many-to-one/one-to-many relationship, multiple source objects can have relationship with same target object or same target object will have multiple source objects and from both direction the navigation is possible. Let’s consider CD and Artist. So multiple CDs can be written by same Artist or same Artist can have multiple CDs. So we will create two tables CD and Artist in the database and we will see how many-to-one/one-to-many relationship work step by step.

Now we will apply many-to-one/one-to-many relationship. So multiple CDs can be written by same Artist or the same Artist can have multiple CDs. Continue reading “Bidirectional Many-To-One/One-To-Many Relationship in Hibernate”

Unidirectional Many-To-One Relationship in Hibernate

In unidirectional association, we will have navigation only in one direction, i.e, only one side of the association will have the reference to the other side. The one side of the association will implement one of the collection interfaces, if it has the reference to the other entity.

In many to one relationship, multiple source objects can have relationship with same target object. Let’s consider CD and Artist. So multiple CDs can be written by same Artist or multiple Artists can write the same CD. So we will create two tables CD and Artist in the database and we will see how many-to-one relationship works step by step.

Now we will apply many-to-one relationship. So multiple CDs can be written by same Artist. Continue reading “Unidirectional Many-To-One Relationship in Hibernate”

Second Level OSCache example in Hibernate

This tutorial will sow how we can configure second level cache using OSCache in Hibernate step by step. We know that there are three types of caching mechanism in Hibernate such as First Level – Session, Second Level – SessionFactory and Query Level – SessionFactory.

For more information on First Level, Second Level and Query Level please go through Hibernate Caching strategy. Continue reading “Second Level OSCache example in Hibernate”

Second level EHCache example in Hibernate

This tutorial will sow how we can configure second level cache using ehcache in Hibernate step by step. EH stands for Easy Hibernate. We know that tehre are three types of caching mechanism such as First Level – session, Second Level – SessionFactory and Query Level – SessionFactory.

For more information on First Level, Second Level and Query Level please go through Hibernate Caching strategy. Continue reading “Second level EHCache example in Hibernate”

Integrate Spring 3, Struts 2 and Hibernate 3

This tutorial shows how to integrate Spring 3, Struts 2 and Hibernate 3 in the following example. In this example Struts 2 will be used as a web framework and Spring 3 will be used as a core service.

You may also like to read:

Struts 2, Spring 4, Hibernate 4 and Maven Integration

Download the required jars for Spring from https://spring.io, Struts from http://struts.apache.org/download.cgi#struts2316 and Hibernate from http://hibernate.org/orm/downloads/

Create web application using Eclipse or any Java based IDE. Continue reading “Integrate Spring 3, Struts 2 and Hibernate 3”