-->
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: LazyInitializationException and JDBCConnectionException
PostPosted: Mon Apr 28, 2008 6:00 am 
Newbie

Joined: Mon Apr 28, 2008 5:14 am
Posts: 1
Hello everyone,

I'am using Hibernate V2, without Spring.

On my class SptUserImpl , I have "lazy=true" on a collection.

Here is my mapping :
Code:
<hibernate-mapping>
    <class
        name="sg.sprint.core.logic.bean.common.user.SptUserImpl"
        table="UserLogin">
      <bag
           name="clientLegalVisibilityCodes"
           table="UserLegalEntity"
           lazy="true"
           cascade="none">

   <key
         column="UserId">
   </key>

            <element
                column="LegalEntityCode"
                type="string"
                not-null="false"
                unique="false"/>

</bag>
  </class>

</hibernate-mapping>


When I load the user, I do :
Code:

public SptUser loadUserLegalEntity(SptUser user) throws DatabaseException {
    SptUserImpl userImpl = (SptUserImpl) user;
    Session s = null;
    try {
      s = openSession();
      s.load(userImpl, userImpl.getId());
      if (!Hibernate.isInitialized(userImpl.getClientLegalVisibilityCodes())) {
        Hibernate.initialize(userImpl.getClientLegalVisibilityCodes());
      }
    } catch (HibernateException e) {
      handleHibernateException(e, methodName);
    } catch (Throwable t) {
      handleUnexpectedException(t, methodName);
    } finally {
      closeSession(s, methodName);
    }
    return userImpl;
  }


This method generate a LazyInitializationException :

Code:
Class :
class net.sf.hibernate.LazyInitializationException

Cause :
net.sf.hibernate.exception.JDBCConnectionException: could not initialize collection:


But not all the times ! Often enough to bother my users but not every time.

Can anyone explain to me where this JDBCConnectionException comes from ?

Thank you in advance


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.