aspose file tools*
The moose likes Other Application Frameworks and the fly likes Hibernate Dialect must be explicitly set Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "Hibernate Dialect must be explicitly set" Watch "Hibernate Dialect must be explicitly set" New topic
Author

Hibernate Dialect must be explicitly set

Niklas Johansson
Greenhorn

Joined: Apr 20, 2009
Posts: 4
Hello,

Using
Hibernate 3.3.1 GA
Hibernate Annotations 3.4.0 GA
JEE 5
JSE 1.6
Eclipse 3.4.1
MySQL 5.0

I am trying to learn Hibernate using annotations. I have managed to get it working not using annotations but when I am converting to annotations things does not work that smooth anymore.

I have tried putting the connection properties in both hibernate.properties XOR hibernate.cfg.xml with no improvements. I found this link wich can be a hint (that can help someone wiser than me...): http://wyding.blogspot.com/2009/03/why-you-got-hibernate-dialect-must-be.html And yes, I am using Eclipse Ganymede.

hibernate.properties:




hibernate.cfg.xml



In my HibernateUtil class i changed
sessionFactory=new Configuration().configure().buildSessionFactory()
to
sessionFactory = new AnnotationConfiguration().buildSessionFactory()
I have seen in some instructions that
sessionFactory = new AnnotationConfiguration().configure().buildSessionFactory()
is used instead, but then I get the error:
/hibernate.cfg.xml not found
instead.

When searching for this problem there are a lot of people having the same problem but I cannot find any answers... And if there are any answers on hibernates own forum it's impossible to find out now since the site has been unavailable for a few days already...

Any help would be most apreciated, about to get a bit (just a little...eh) frustrated.

Thank you in advance!

Regards,
Niklas
Niklas Johansson
Greenhorn

Joined: Apr 20, 2009
Posts: 4
I found the solution:

The suggestion to change

sessionFactory=new Configuration().configure().buildSessionFactory()


to

sessionFactory = new AnnotationConfiguration().buildSessionFactory()


does not work but either of following works:

sessionFactory = new AnnotationConfiguration().configure().buildSessionFactory()


or

AnnotationConfiguration scfg = new AnnotationConfiguration();
scfg.configure();
sessionFactory=scfg.buildSessionFactory();


Also, I had some other errors along the road which made me think that either of the two working solutions wasn't working, but they did at the end.

Hope this can help someone else with the same problem!

Regards,
Niklas
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17257
    
    6

Also this isn't the forum for Hibernate questions. Our Object Relation Mapping forum is where you put Hibernate questions.

So I am going to move this to that forum

Thanks

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Hibernate Dialect must be explicitly set