Online Hibernate Training just in Rs. 1000

One week online training in Hibernate ORM framework. Learn Hibernate Framework and enhance your skills. Best Online Hibernate training at 90% discount. Join Now!! Offer is valid Only for limited Period!!! Online Training

Hibernate 4 AnnotationSessionFactoryBean

Learn about Hibernate4 AnnotationSessionFactoryBean and understand what is the correct solution.


How to write hello world example program in Hibernate? How to create one to one relationship in Hibernate 4 with Annotation? How to calculate minimum in Hibernate using the min() Function Hibernate 4.3.4 Released: Hibernate 4.3.4.Final Maven dependency Hibernate 4.3 Hello World: Example How to create SessionFactory in Hibernate 4.3.1? Hibernate 4 Hello World: Example of Hello World program Hibernate 4 create Session Factory: Example of creating Session Factory in Hibernate 4 Hibernate 4.3 and JPA 2.1 Example What is Hibernate in Java? Hibernate Overview and Architecture What is JPA 2.1? Hibernate 4.3.0.Final Maven dependency Hibernate 4.3 ORM Features Hibernate 4.3 Tutorial Hibernate Criteria average example Hibernate Criteria load all objects from table Hibernate Criteria Hibernate beginner tutorial Hibernate Session.delete() Example Hibernate save or update method example Hibernate Load Example Hibernate save Example - Rose India Hibernate 4 tutorials Hibernate Example Step by Step in Eclipse Hibernate Configuration files Setup Hibernate Environment Hibernate Architecture Hibernate Overview Hibernate 4.2 Tutorial Hibernate 4 Annotations Tutorial Hibernate 4 AnnotationSessionFactoryBean hibernate versions hibernate jndi hibernate tomcat hibernate metamodel generator hibernate entity Seam Hibernate C3P0 Hibernate hibernate shard hibernate means temporal hibernate jsf hibernate spring j2ee hibernate spring hibernate encrypted password alias_to_entity_map hibernate temporal jsf spring hibernate hibernate by example hibernate repository hibernate sample code

Hibernate 4 AnnotationSessionFactoryBean

How to use AnnotationSessionFactoryBean in Hibernate 4? Can it be used?

In this tutorial we are going to explain you about Hibernate4 AnnotationSessionFactoryBean which is not available in Hibernate 4. As a part of migration process of your Hibernate 3 application to Hibernate 4 you have to make necessary changes in your configuration files. This tutorial explains you how to update from Hibernate 3 to Hibernate 4.

Here is the video tutorial of: "How to use Hibernate 4 AnnotationSessionFactoryBean?"

If you use the following code in your Hibernate 4 application it will give you the error. Code used in Spring 3:

<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"/>

Application may give the following error:

nested exception is java.lang.NoClassDefFoundError: Lorg/hibernate/cache/CacheProvider;

So, you have to use the org.springframework.orm.hibernate4.LocalSessionFactoryBean instead of AnnotationSessionFactoryBean. So this change is required as a process of migration to Hibernate 4.

In the Hibernate 4 the CacheProvider-related interfaces and classes has been removed. Now the RegionFactory related cache interfaces are available for secondary level caching.

Here is the complete code of using the LocalSessionFactoryBean instead of AnnotationSessionFactoryBean in Hibernate 4 applications:

<bean id="sessionFactory"

<bean id="transactionManager"
<property name="sessionFactory" ref="sessionFactory" />

You can include the above code in your application configuration file.

More tutorials of Hibernate 4:


Share on Google+Share on Google+

Hibernate 4 AnnotationSessionFactoryBean

Posted on: August 27, 2013 If you enjoyed this post then why not add us on Google+? Add us to your Circles



Discuss: Hibernate 4 AnnotationSessionFactoryBean  

Post your Comment

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image