-->
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.  [ 2 posts ] 
Author Message
 Post subject: Exception initializing proxy error
PostPosted: Fri Mar 18, 2005 1:25 pm 
Beginner
Beginner

Joined: Wed Feb 23, 2005 9:24 am
Posts: 28
I'm getting an exception while using the criteria api to fetch some data:

ERROR [LazyInitializer] Exception initializing proxy
net.sf.hibernate.HibernateException: Could not initialize proxy - the owning Session was closed

Here is the code :

public Object doInHibernate(Session session) throws HibernateException
{
Criteria criteria = session.createCriteria(TStructureSocieteGestion.class);
//criteria.setFetchMode("structure", FetchMode.LAZY);
criteria.add(Expression.eq("structure.codeStructure", codeStructure));
criteria.add(Expression.eq("structure.codeStructure", codeStructure));
criteria.add(Expression.le("dateDebutValidite", now));
criteria.add(Expression.ge("dateFinValidite", now));

return criteria.uniqueResult();

}

Does it means something to somebody ?

Thanks in advance.

Meissa


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 18, 2005 2:30 pm 
Expert
Expert

Joined: Fri Nov 07, 2003 4:24 am
Posts: 315
Location: Cape Town, South Africa
I don't think the error is ocurring here. It's probably ocurring when you access the returned instance of TStructureSocieteGestion from the query. It is being proxied and you are probably outside the scope of a session.

try this
Code:
public Object doInHibernate(Session session) throws HibernateException
{
    Criteria criteria = session.createCriteria(TStructureSocieteGestion.class);
   //criteria.setFetchMode("structure", FetchMode.LAZY);
    criteria.add(Expression.eq("structure.codeStructure", codeStructure));
    criteria.add(Expression.eq("structure.codeStructure", codeStructure));
    criteria.add(Expression.le("dateDebutValidite", now));
    criteria.add(Expression.ge("dateFinValidite", now));

    Object result = criteria.uniqueResult();
    Hibernate.initialize(result);
    return result;
}


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