-->
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: Associateing a collection with two open sessions
PostPosted: Tue Apr 27, 2004 4:41 am 
Newbie

Joined: Tue Apr 27, 2004 3:47 am
Posts: 1
Hi everyone

We have some problems with connection pooling.

We have built a server using Hibernate 2.1.2 (of course) and use SOAP technology with resin. Also we are using the following configuration in hibernate.properties:


hibernate.connection.provider_class = net.sf.hibernate.connection.DBCPConnectionProvider
hibernate.dbcp.validationQuery=Select 1
hibernate.dbcp.maxActive=10
hibernate.dbcp.maxIdle=5
hibernate.dbcp.maxWait=3000
hibernate.dbcp.whenExhaustedAction=1

hibernate.dbcp.ps.maxActive=50
hibernate.dbcp.ps.maxIdle=10
hibernate.dbcp.ps.maxWait=3000
hibernate.dbcp.ps.whenExhaustedAction=1


When I delete an object I get the following error:


09:25:21,400 ERROR HibernatePropertyGroupFactory:196 - ***ERROR: net.sf.hibernate.HibernateException: Illegal attempt to associate a collection with two open sessions
09:25:21,406 ERROR HibernatePropertyGroupFactory:206 - ***ERROR: net.sf.hibernate.HibernateException: Session already disconnected


The code I use looks typically like this:

Code:
public List find(String pHql) {
    List list = null;
    try {
        session = factory.openSession();
        list = session.find(pHql);
        session.flush();

    } catch (HibernateException e) {
        if (session != null){
            try {
               session.flush();
               session.disconnect();
            } catch (HibernateException ex) {
                throw new BackendException(
                    " Could not Close Connection.",
                    ex);
            }
        }
        String err = "   ***ERROR: executing '" + pHql + "'. ";
        throw new BackendException(err, e);
    } finally {
        if (session != null){
            try {
               session.flush();
               session.disconnect();
            } catch (HibernateException e) {
                throw new BackendException(
                    " Could not Close Connection.",
                    e);
            }
        }
    }

    if (list == null)
        list = new java.util.ArrayList();

    return (list);
}


My hypothesis is that the pooling causes the error. I know that I need to return the connection to the pool not the session but I am uncertain how. After searching at google on the subject I think I know how. My interpretation of the information I found was that I disconnect the connection from the session with session.disconnect() and then the connection is returned to the pool. So my first question is if session.disconnect() returns the connection to the pool? My second question is how do I fix the errors that appear in my log (see above errors). The third question is do I need to close the session after I have disconnected it from the connection (the API say that I don't)?

Thanks in before half
Oscar Norlander


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.