Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

Hibernate Configuration  RSS feed

 
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.
 
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 !!!
 
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?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!