How to initialize annotation configuration instance in Hibernate 4?

191 views Asked by At

I am using hibernate-release-4.2.4.Final version and tried using annotations instead of the hbm.xml file. But while running, it always throws an-annotation-configuration-instance-is-required-to-use-error.

When I tried importing org.hibernate.AnnotationConfiguration it showed the class was deprecated.

Then I tried copying Annotation configuration class file from the hibernate-annotation.jar and used and it in the hibernate3.jar and it worked fine.

My question is how to initialize a annotation configuration instance in the newer version of Hibernate release?

1

There are 1 answers

0
Roman C On

In Hibernate 4 you should not use AnnotationConfiguration anymore, use Configuration instead.

Use HibernateUtils or other session factory builder to build the session factory.

An example of such utility you could find here.