-->
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.  [ 5 posts ] 
Author Message
 Post subject: Handling Session
PostPosted: Thu Aug 13, 2009 12:16 pm 
Newbie

Joined: Wed Jul 15, 2009 12:19 pm
Posts: 5
Hi,

I have 2 applications that use the same database, one is the application for the Administrator, where all the configuration is done.
The second application is where the users take examens that the Administrator assigned. The 2 application are in separated wars.
The problem is that if the Administrator in his application assign a Exam to a user, the change in the second application for normal user is not registered. After every commit I flush the session in the Administrator application.

The way I create and handle the session in both application is in the following way.

Code:
  public class HibernateUtil {
    private static SessionFactory sessionFactory;
 
    static {
        try {
            sessionFactory = new AnnotationConfiguration().configure().buildSessionFactory();
        } catch (Throwable ex) {
            System.err.println("Initial SessionFactory creation failed." + ex);
            throw new ExceptionInInitializerError(ex);
        }
    }

    public static Session getSession() throws HibernateException {
        return sessionFactory.openSession();
    }
}


Thanks in advanced


Top
 Profile  
 
 Post subject: Re: Handling Session
PostPosted: Thu Aug 13, 2009 1:54 pm 
Newbie

Joined: Tue Feb 24, 2009 8:39 pm
Posts: 19
Please give us more information.
Your DBMS, hibernate version, etc.

...
What if you use a param like hibernate.connection.isolation = 2

meanwhile I hope it helps


Top
 Profile  
 
 Post subject: Re: Handling Session
PostPosted: Thu Aug 13, 2009 2:01 pm 
Newbie

Joined: Wed Jul 15, 2009 12:19 pm
Posts: 5
Im using MySQL, hibernate version 3
By now I'm trying to reconnect and disconnect the session in the second application, I don't know if it works and the impact in the response to each query.

Thanks!


Top
 Profile  
 
 Post subject: Re: Handling Session
PostPosted: Thu Aug 13, 2009 5:16 pm 
Newbie

Joined: Wed Jul 15, 2009 12:19 pm
Posts: 5
Thank you hi-tech

That resolve my problem.


Top
 Profile  
 
 Post subject: Re: Handling Session
PostPosted: Thu Aug 13, 2009 5:29 pm 
Newbie

Joined: Tue Feb 24, 2009 8:39 pm
Posts: 19
So, you must read about transactions, http://docs.jboss.org/hibernate/stable/ ... ansactions
And if you are writing a webapp, you must read about OpenSessionInView design pattern, https://www.hibernate.org/43.html


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