-->
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: Session.connection() and ResultSet (connection closed??)
PostPosted: Wed Dec 24, 2008 7:21 am 
Newbie

Joined: Thu Dec 18, 2008 12:42 pm
Posts: 2
Hi to all,
I am new whit hibernate and have a "little problem":
I am integrating hibernate into an existing web application, so I have to use the Session.connection() method to obtain a connection. All work, but in some cases that's something strange.
This is the sequence:
Code:

3*
PreparedStatement ps=Connection.prepareStatement("sql");
ResultSet rs=ps.executeQuery();
do{

4*

5*


6* }while(rs.next());


1) //web request, open session by hibernate

2) //obtain a connection by calling Session.connection() to work with old business objects

3) //execute a select with connection and ResultSet

4) // do some work with connection and "only load" new objects whit hibernate

5) //insert  with connection and old object

6) //call resultSet.next() until there is records from point 3



the problem is at point 6. If i load new object with hibernate session, when i call rs.next() it throws an

Code:
java.sql.SQLException: Connection closed: next


if I remove the loading by hibernate session the next() works.
The strang think is that if i put some System.out just before next() call, this is the state of connection/session:
Code:
java.sql.Connection.isClosed() : false
getHibernateSessionDB().isConnected() : true
getHibernateSessionDB().isDirty() : false
getHibernateSessionDB().isOpen() : true


thanks to all


Top
 Profile  
 
 Post subject: [resolved] connection closed
PostPosted: Mon Dec 29, 2008 4:56 am 
Newbie

Joined: Thu Dec 18, 2008 12:42 pm
Posts: 2
If it can help anyone I resolved by executing the sql query directily via Session.createSQLQuery(), fetching all results before enumerate them with method list() of returned object SQLQuery.


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.