-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: "hibernate.dialect not set" with hibernate.cfg.xml
PostPosted: Tue Nov 04, 2003 9:22 pm 
Beginner
Beginner

Joined: Tue Sep 23, 2003 5:00 pm
Posts: 40
Hi,

My hibernate mapping works when I configure it with an "hibernate.properties".

I would like to make it work with an "hibernate.cfg.xml" file.

Here is my configuration file :

Code:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
        "-//Hibernate/Hibernate Configuration DTD 2.0//EN"

"http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">

<hibernate-configuration>

    <session-factory>
   <property name="query.substitutions">true 1, false 0, yes 'Y', no 'N'</property>
   <property name="dialect">net.sf.hibernate.dialect.MySQLDialect</property>
   <property name="connection.driver_class">com.mysql.jdbc.Driver</property>
   <property name="connection.url">jdbc:mysql://localhost/proyecto</property>
   <property name="connection.username"></property>
   <property name="connection.password"></property>
   <property name="connection.pool_size">1</property>
   <property name="statement_cache.size">25</property>
   <property name="proxool.pool_alias">pool1</property>
   <property name="hibernate.show_sql">true</property>
   <property name="jdbc.batch_size">0</property>
   <property name="jdbc.use_streams_for_binary">true</property>

   <mapping resource="com/logis/proyecto/persistence/Persistent1.hbm.xml"/>
   <mapping resource="com/logis/proyecto/persistence/Persistent2.hbm.xml"/>
   </session-factory>

</hibernate-configuration>


When I execute the following piece of code :

Code:
sessionFactory = new Configuration().configure().buildSessionFactory();
Configuration cfg = new Configuration();
new SchemaExport(cfg).create(true, true);


All the properties are set except the dialect.

I get the following error message :
Quote:
net.sf.hibernate.HibernateException: The dialect was not set. Set the property hibernate.dialect.
at net.sf.hibernate.dialect.Dialect.getDialect(Dialect.java:273)
at net.sf.hibernate.dialect.Dialect.getDialect(Dialect.java:294)
at net.sf.hibernate.tool.hbm2ddl.SchemaExport.<init>(SchemaExport.java:46)
at net.sf.hibernate.tool.hbm2ddl.SchemaExport.<init>(SchemaExport.java:37)
at com.logis.proyecto.persistence.MainClass.exportTables(MainClass.java:36)
at com.logis.proyecto.persistence.MainClass.main(MainClass.java:93)


If you have any suggestions ...

sylvain_2020


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 04, 2003 9:38 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Quote:
sessionFactory = new Configuration().configure().buildSessionFactory();
Configuration cfg = new Configuration();
new SchemaExport(cfg).create(true, true);


look again.


It should be:

Code:
Configuration cfg = new Configuration().configure();
new SchemaExport(cfg).create(true, true);
cfg.buildSessionFactory();


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 05, 2003 10:56 am 
Beginner
Beginner

Joined: Tue Sep 23, 2003 5:00 pm
Posts: 40
Hi,

That works !

Thank you for your answer and sorry for the silly question.

sylvain_2020


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.