11 Jul

JSF 2, Spring 4, Hibernate 4 and Maven Integration

In this tutorial I will show you how to integrate JSF 2, Spring 4, Hibernate 4 and Maven. In the previous example Spring 3, JSF 2 and Hibernate 3 integration example , I have shown how to integrate JSF 2, Spring 3 and Hibernate 3 but I have not used maven there.

For this tutorial we will create maven based web project in Eclipse.

If you already have an idea on how to create a maven project in Eclipse will be great otherwise I will tell you here how to create a maven project in Eclipse.

Prerequisites

The following configurations are required in order to run the application

Eclipse Kepler
JDK 1.8
Tomcat 8
Have maven installed and configured
JSF 2, Spring 4, Hibernate 4 dependencies in pom.xml

Now we will see the below steps how to create a maven based project in Eclipse Read More

06 Jul

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. Read More

04 Jul

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. Read More

14 Jun

Important properties in hibernate configuration file

There are mainly six important tags for hibernate configuration file. Hibernate configuration file naming convension 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 hibernate.properties file. Read More

14 Jun

Stored procedure example in Hibernate

This tutorial shows how we can call stored procedure in Hibernate API.

Prerequisites

Hibernate 3.x jars, mysql-connector-java jar, jdk 1.6, MySQL 5.x

stored procedure example in hibernate

1. Create a Store Procedure in MySQL in database cdcol

 

Read More

14 Jun

Hibernate Inheritance strategy: Table Per Class Hierarchy

I am going to give explaination and example on hibernate table per class hierarchy, consider we have base class named Person and two derived classesStudent and Teacher

If we save the derived class object like Student or Teacher then automatically Person class object will also be saved into the database, and in the database all the data will be stored into a single table only, which is base class table for sure.

But here we must use one extra discriminator column in the database to identify which derived class object we have  saved in the table along with the base class object. This discriminator column is mandatory otherwise hibernate will throw an exception. Read More

14 Jun

Hibernate Inheritance strategy: Table Per SubClass Hierarchy

In Table Per SubClass Hierarchy there will be the number of classes equals to the number of tables in the database.
If we save the Student class object, hibernate will first save the data related to super class object into the super class related table in the database and then Student object data in Student related table in the database. Read More

14 Jun

Hibernate Inheritance strategy: Table Per Concrete Class Hierarchy

In Table Per Concrete Class Hierarchy will have the number of tables in the database equals to the number of derived classes. Once we save the derived class object, then derived class data and base class data will be saved in the derived class related table in the database. We need the tables only for derived classes. For this in the hibernate mapping file we need to use one new element <union-subclass/> under <class/> tag. Read More

14 Jun

Different types of cache strategies in Hibernate

Hibernate uses two different caches for objects: first-level cache and second-level cache.

First-level cache is associated with the Session object, while second-level cache is associated with the SessionFactory object. By default, Hibernate uses first-level cache on a per-transaction basis. Hibernate uses this cache mainly to reduce the number of SQL queries it needs to generate within a given transaction. Read More

14 Jun

Criteria API example in Hibernate

Criteria is a simplified API for retrieving entities by composing Criterion objects. This is a very convenient approach for functionality like “search” screens where there is a variable number of conditions to be placed upon the result set.

The following example shows how to work with Hibernate Criteria API. Read More

Share