• 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 Configuration

 
Ranch Hand
Posts: 280
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
reply
    Bookmark Topic Watch Topic
  • New Topic