• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Hibernate Dialect must be explicitly set

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
It would give a normal human mental abilities to rival mine. To think it is just a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic