-->
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.  [ 1 post ] 
Author Message
 Post subject: Mapping loading problems
PostPosted: Thu Feb 10, 2005 9:23 am 
Beginner
Beginner

Joined: Tue Dec 21, 2004 11:53 am
Posts: 42
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?


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

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.