Read the rules before posting!
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:2.0.3
Hi there. We have an application running on a managed env. So far it has no problems at all. Now I decided to create a diferent configuration to use in test cases, so instead of getting the datasource from a jndi I use a plain jdbc configuration. Problem is, When running my tests, it seems that the test tries to run the DAO method before the mappings were loaded. Here's how my hibernateUtil seems like:
Code:
static {
try {
props.load(new FileInputStream(propertiesFile));
hibernateFile = props.getProperty("hibernate.mapping.file");
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
try {
sessionFactory = new Configuration().configure("/"+hibernateFile).buildSessionFactory();
} catch (HibernateException ex) {
throw new RuntimeException("Exception building SessionFactory: " + ex.getMessage(), ex);
}
}
public static Session currentSession() throws HibernateException {
Session s = (Session) session.get();
// Open a new Session, if this Thread has none yet
if (s == null || !s.isOpen()) {
s = sessionFactory.openSession();
session.set(s);
}
return s;
}
And each method on DAO calls the HibernateUtil.currentSession to obtain a new session.
This works fine on a deployed version of the app.
Any ideas?