-->
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: Criteria.List()
PostPosted: Thu Jul 22, 2004 4:29 pm 
Beginner
Beginner

Joined: Tue Jun 29, 2004 3:44 pm
Posts: 43
What does Criteria.list() return?
A List, obviously, but is it a session dependent list?

I need a detached List of objects, so I have this method:
Code:
   public List getAll(Class c) throws HibernateException {
      Session session = HibernateUtil.currentSession();
      Criteria crit = session.createCriteria(c);
      List list = new ArrayList(crit.list());
      HibernateUtil.closeSession();
      return list;
   }


Which results in a:
java.sql.SQLException: Operation not allowed after ResultSet closed

If I don't close the session in that method (by just commenting out that line), I get no exception.

It's taken me a long time to track the error this far, and I'm not positive it's coming from this method. But commenting/uncommenting that line toggles the existence of the exception.

Any suggestions?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 22, 2004 5:06 pm 
Beginner
Beginner

Joined: Tue Jun 29, 2004 3:44 pm
Posts: 43
Never mind.

The list was not a problem at all. The problem was that this method was being called from within another method that got and used the same session. It was a delete method that ended up calling this method to instantiate an object to delete. The method I posted closed the session that both methods were using.

I'm going to get an ulcer.


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.