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)
|