This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate Configuration

 
Siddharth Bhargava
Ranch Hand
Posts: 280
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was doing configuration of hibernate by using hibernate.properties file ONLY. Is it necessary that along with hibernate.properties file that we also have hibernate.cfg.xml file also. The code is as under :

hibernate.properties



Main Application




I am getting the following exception.


org.hibernate.HibernateException: Hibernate Dialect must be explicitly set
at org.hibernate.dialect.DialectFactory.determineDialect(DialectFactory.java:57)
at org.hibernate.dialect.DialectFactory.buildDialect(DialectFactory.java:39)
at org.hibernate.cfg.SettingsFactory.determineDialect(SettingsFactory.java:426)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:128)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2009)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1292)
at com.hibernateexample.onetoone.AssociationOneToOneMapping.main(AssociationOneToOneMapping.java:20)



Please help me !!!
I am unable to understand the logic behind this - if we are writing all the properties in hibernate.properties then why do we need hibernate.cfg.xml file.
 
Edvins Reisons
Ranch Hand
Posts: 364
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A remark on the syntax: in the original hibernate.properties files, properties are specified without the equals sign, like:



And make sure that the file is at the root of the classpath.
 
Siddharth Bhargava
Ranch Hand
Posts: 280
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have my hibernate.properties in the root of the classpath. I have tried with modifed syntax also as well as with the equal(=) also. Now I am not getting an exception but now the problem is that even if I am giving wrong values in the hibernate.properties file even then its working (i.e printing Done) only when i give wrong value of hibernate.connection.driver_class does it gives an error. Please help !!!
 
Joe Harry
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do we have to pass to the mapping file information to the configure () method? Because when we have the XML configuration, we can just use configure () but when the name of the XML file is different, other than hibernate.cfg.xml, we pass the name of the XML file to the configure () method. Similarly, for the above case, do we have to pass the hibernate.properties as a parameter to the configure () method??

I'm just not hijacking this thread, but I was wondering if this could be linked to the problem that was posted above?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic