Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Hibernate config - works with .properties not with .cfg.xml

Reply
Thread Tools

Hibernate config - works with .properties not with .cfg.xml

 
 
icogs
Guest
Posts: n/a
 
      11-20-2007
I have just started working with Hibernate and I am having trouble
using hibernate.cfg.xml in place of hibernate.properties.

This rather minimal .properties file works fine:

hibernate.dialect=org.hibernate.dialect.DerbyDiale ct
hibernate.connection.driver_class=org.apache.derby .jdbc.EmbeddedDriver
hibernate.connection.url=jdbc:derby:MyDB
hibernate.connection.pool_size=10

However when I try the following hibernate.cfg.xml instead it doesn't
appear to pick up any configuration at all:

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
<session-factory>
<property
name="connection.driver_class">org.apache.derby.jd bc.EmbeddedDriver</
property>
<property name="connection.url">jdbc:derby:MyDB</property>
<property name="connection.pool_size">10</property>
<property name="dialect">org.hibernate.dialect.DerbyDialect</
property>
</session-factory>
</hibernate-configuration>

I am just using core Java in Eclipse and have placed both files at the
root of my classpath in the bin directory. Attempting to run
with .cfg.xml gives me the following output:

20-Nov-2007 17:23:28 org.hibernate.cfg.Environment <clinit>
INFO: Hibernate 3.2.5
20-Nov-2007 17:23:28 org.hibernate.cfg.Environment <clinit>
INFO: hibernate.properties not found

and further down:

20-Nov-2007 17:23:28
org.hibernate.connection.UserSuppliedConnectionPro vider configure
WARNING: No connection properties specified - the user must supply
JDBC connections
Exception in thread "main" org.hibernate.HibernateException: Hibernate
Dialect must be explicitly set
at
org.hibernate.dialect.DialectFactory.determineDial ect(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(Se ttingsFactory.java:
12
at org.hibernate.cfg.Configuration.buildSettings(Conf iguration.java:
2009)
at
org.hibernate.cfg.Configuration.buildSessionFactor y(Configuration.java:
1292)
at com.icogs.mailist.security.ListLists.main(ListList s.java:17)

Is my .cfg.xml file wrong or just not being found? I don't know where
else to put it, it is in the classpath.

 
Reply With Quote
 
 
 
 
Arne Vajh°j
Guest
Posts: n/a
 
      11-25-2007
icogs wrote:
> I have just started working with Hibernate and I am having trouble
> using hibernate.cfg.xml in place of hibernate.properties.
>
> This rather minimal .properties file works fine:
>
> hibernate.dialect=org.hibernate.dialect.DerbyDiale ct
> hibernate.connection.driver_class=org.apache.derby .jdbc.EmbeddedDriver
> hibernate.connection.url=jdbc:derby:MyDB
> hibernate.connection.pool_size=10
>
> However when I try the following hibernate.cfg.xml instead it doesn't
> appear to pick up any configuration at all:


> 20-Nov-2007 17:23:28 org.hibernate.cfg.Environment <clinit>
> INFO: Hibernate 3.2.5
> 20-Nov-2007 17:23:28 org.hibernate.cfg.Environment <clinit>
> INFO: hibernate.properties not found


How do you attempt to instantiate your SessionFactory ?

Arne
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Hibernate LazyInitializationException in web application Struts asMVC, Spring as IOC and Hibernate as ORM layer Amit Jain Java 7 04-27-2009 10:27 AM
HIBERNATE - java.lang.NoClassDefFoundError: org/hibernate/cfg/Configuration Eleanna Skouta Java 2 12-09-2008 02:09 AM
Hibernate cannot find hibernate.cfg.xml jstorta Java 1 01-19-2008 01:45 PM
Hibernate Syncronizer now generates code for Hibernate 3.0 msenin@covad.net Java 0 07-14-2005 05:47 AM
[HIBERNATE] [EVALUATION] - Gavin King Censors Hibernate Forum Ilias Lazaridis Java 0 12-27-2004 04:26 AM



Advertisments