Unidirectional One-To-Many Relationship with Join Tables 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 one to many relationship, multiple target objects can have relationship with…

Bidirectional One-To-One Relationship on Primary Key in Hibernate

In bidirectional association, we will have navigation 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 one to one relationship, one source object can have relationship with only one…

Bidirectional One-To-One Relationship on Foreign Key in Hibernate

In bidirectional association, we will have navigation in both directions, 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 one to one relationship, one source object can have relationship with only one…

Unidirectional One-To-One Relationship on Primary Key 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. In one to one relationship, one source object can have relationship with only one target object. Let’s consider CD and Artist. So one CD can be written by one Artist or an Artist can…

Unidirectional One-To-One Relashionship on Foreign Key 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. In one to one relationship, one source object can have relationship with only one target object. Let’s consider CD and Artist. So one CD can be written by one Artist or only one Artist…

Spring Data JPA Bidirectional Many-To-One/One-To-Many Relationship

Introduction In bidirectional association, you 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…

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…

Second level EHCache example in Hibernate 5

Introduction This tutorial will show second level ehcache example in Hibernate 5. EH stands for Easy Hibernate. We know that there are three types of caching mechanism such as First Level – session, Second Level – SessionFactory and Query Level – SessionFactory. Caching mechanism improves the performance of application because the data are loaded from cache instead of hitting the…

Important properties in hibernate configuration file

There are mainly six important tags or properties for hibernate configuration file. Hibernate configuration file naming convention is generally hibernate.cfg.xml and it is generally placed in the classpath. This can also be configured in the hibernate.properties file. If both hibernate.cfg.xml and hibernate.properties are found in the classpath then hibernate.cfg.xml overrides the hibernate.properties file.

Stored procedure example in Hibernate

Introduction In this tutorial I will show you how to call stored procedure using Hibernate framework. I will show you both XML and Annotation based configurations for calling stored procedure. We will use MySQL database to create and call stored procedure. We will also use both maven and gradle build tools to build the example application.