-->
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.  [ 2 posts ] 
Author Message
 Post subject: Hibernate Dialect must be explicitly set
PostPosted: Mon May 28, 2007 7:49 am 
Newbie

Joined: Mon Dec 11, 2006 12:54 am
Posts: 14
Hi,

I am trying to create a small java class and use hibernate..But i'm getting the following error:

Exception in thread "main" 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:378)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:110)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1881)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1174)

The java class is :
public class TestExample {

private SessionFactory factory;


public void createHoney(Honey honey){
Transaction tx = null;
Session s = factory.openSession();
try{
tx = s.beginTransaction();
s.save(honey);
tx.commit();
s.close();
}catch(HibernateException he){
he.printStackTrace();
if(tx != null && tx.isActive())
tx.rollback();
}
}

public void deleteHoney(Honey honey){
Session s = factory.openSession();
Transaction tx = null;
try{
tx = s.beginTransaction();
s.delete(honey);
tx.commit();
s.close();
}catch(HibernateException he){
he.printStackTrace();
if(tx != null && tx.isActive())
tx.rollback();
}
}

public void listHoney(){
Transaction tx = null;
Session s = factory.openSession();
try{
tx = s.beginTransaction();
List honeys = s.createQuery("select h from Honey as h").list();
for(Iterator it = honeys.iterator(); it.hasNext();){
Honey hon = (Honey) it.next();
System.out.println("Id : " + hon.getId() + "Honey : " + hon.getName() + " Taste : " + hon.getTaste());
}
tx.commit();
s.close();

}catch(HibernateException he){
he.printStackTrace();
if(tx != null && tx.isActive())
tx.rollback();
}


}

public static void main(String[] args) {

TestExample test = new TestExample();

Configuration cfg = new Configuration()
.addClass(Honey.class)
.setProperty(Environment.HBM2DDL_AUTO,"create");


test.factory = cfg.buildSessionFactory();

Honey forestHoney = new Honey();
Honey countryHoney = new Honey();
forestHoney.setName("Forest honey");
forestHoney.setTaste("very sweet");
countryHoney.setName("Country honey");
countryHoney.setTaste("tasty");

test.createHoney(forestHoney);
test.createHoney(countryHoney);

//test.listHoney();

test.deleteHoney(countryHoney);

test.listHoney();
}

/**
*
*/
public TestExample() {
super();
}
}


Can somebody help?


Top
 Profile  
 
 Post subject: Hibernate Dialect must be explicitly set
PostPosted: Mon May 28, 2007 10:55 am 
Beginner
Beginner

Joined: Wed Apr 18, 2007 6:17 pm
Posts: 49
Location: Dominican Republic
Hi, you should also sets the property hibernate.dialect to the org.cfg.Configuration class. You should go to the session 3.4.1 of the hibernate reference to choose one dialect that suits your database.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.