-->
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: AnnotationConfiguration.setProperties() method broken?
PostPosted: Mon Jan 10, 2005 3:44 pm 
Pro
Pro

Joined: Fri Nov 19, 2004 5:52 pm
Posts: 232
Location: Chicago, IL
Hibernate version: hibernate-3.0beta1, hibernate-annotations-3.0alpha1

I am trying to programmatically configure the properties of my AnnotationConfiguration like the following.

AnnotationConfiguration ac = new AnnotationConfiguration();
Properties p = new Properties();
p.put("hibernate.dialect", "org.hibernate.dialect.SQLServerDialect");
p.put("hibernate.connection.driver_class", "com.inet.tds.TdsDriver");
p.put("hibernate.connection.url", "jdbc:inetdae7:...?database=...");
p.put("hibernate.connection.username", "...");
p.put("hibernate.connection.password", "...");
p.put("hibernate.show_sql", "true");
ac.setProperties(p);
ac.addAnnotatedClass(Item.class);
ac.addAnnotatedClass(Person.class);
ac.addAnnotatedClass(Reservation.class);
ac.addAnnotatedClass(User.class);
SessionFactory sf = ac.buildSessionFactory();

However, I'm receiving a stack trace like the following. It appears to not be setting the dialect property for some reason. Note, I tried code similar to the code listed above, except using Configuration instead and it works fine. Also, previously, I had problems getting it to work using a hibernate.cfg.xml file. The only way I can get it to work is with a hibernate.properties file. Has anyone else ran into this problem?

Full stack trace of any exception that occurs:

[java] Jan 10, 2005 1:28:49 PM org.hibernate.cfg.Environment <clinit>
[java] INFO: Hibernate 3.0 beta 1
[java] Jan 10, 2005 1:28:49 PM org.hibernate.cfg.Environment <clinit>
[java] INFO: hibernate.properties not found
[java] Jan 10, 2005 1:28:49 PM org.hibernate.cfg.Environment <clinit>
[java] INFO: using CGLIB reflection optimizer
[java] Jan 10, 2005 1:28:49 PM org.hibernate.cfg.Environment <clinit>
[java] INFO: using JDK 1.4 java.sql.Timestamp handling
[java] Jan 10, 2005 1:28:49 PM org.hibernate.cfg.AnnotationConfiguration addAnnotatedClass
[java] INFO: Mapping class using metadata: edu.uchicago.at.entity.Item
[java] org.hibernate.HibernateException: The dialect was not set. Set the property hibernate.dialect.
[java] at org.hibernate.dialect.Dialect.getDialect(Dialect.java:419)
[java] at org.hibernate.cfg.AnnotationBinder.bindId(AnnotationBinder.java:859)
[java] at org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:613)
[java] at org.hibernate.cfg.AnnotationBinder.processElementsOfAClass(AnnotationBinder.java:447)
[java] at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:299)
[java] at org.hibernate.cfg.AnnotationConfiguration.addAnnotatedClass(AnnotationConfiguration.java:35)
[java] at ....Test.main(Test.java:38)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 10, 2005 5:43 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
There is a bug in AnnotationConfiguration that currently force you to define the dialect into the hibernate.properties.
It's due to a fix port that was wrong.
See http://opensource.atlassian.com/projects/hibernate/browse/HB-1315
for more informations

I didl rollback the fix in CVS. Thanks for pointing this to me.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 10, 2005 5:48 pm 
Pro
Pro

Joined: Fri Nov 19, 2004 5:52 pm
Posts: 232
Location: Chicago, IL
No problem. Thanks for the great work on implementing annotations and for being helpful in the forum. Much appreciated.


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.