-->
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: Possible Bug. ScrollableResults close() throws exception
PostPosted: Fri Apr 13, 2007 2:27 am 
Beginner
Beginner

Joined: Fri Jan 27, 2006 4:20 am
Posts: 22
Possible Bug. ScrollableResults close() throws exception

Hibernate version: 3.2.3.GA
Hibernate Annotation version: 3.3.0.GA
Hibernate Entity Manager version: 3.3.1.GA
jConnect 6.05 on Sybase ASE 12.5


Full stack trace:

Code:
Exception in thread "main" java.lang.NullPointerException
   at com.sybase.jdbc3.tds.TdsResultSet.next(Unknown Source)
   at com.sybase.jdbc3.tds.TdsResultSet.close(Unknown Source)
   at com.sybase.jdbc3.jdbc.SybResultSet.markDead(Unknown Source)
   at com.sybase.jdbc3.jdbc.SybResultSet.close(Unknown Source)
   at com.sybase.jdbc3.jdbc.SybResultSet.close(Unknown Source)
   at org.hibernate.jdbc.AbstractBatcher.closeQueryStatement(AbstractBatcher.java:206)
   at org.hibernate.impl.AbstractScrollableResults.close(AbstractScrollableResults.java:94)
   at net.brokerhub.otcex.migration.SybaseToMysql.main(SybaseToMysql.java:88)


The code:

Code:
HibernateEntityManager emSybase =
         (HibernateEntityManager) hibEmfSybase.createEntityManager();
      
      HibernateEntityManager emMysql =
         (HibernateEntityManager) hibEmfMysql.createEntityManager();
      
      ScrollableResults sr = emSybase.getSession()
         .createQuery("from Audittrail2")
         .setReadOnly( true )
         .scroll( ScrollMode.SCROLL_INSENSITIVE );
      
      sr.close();
      emSybase.close();


Is there any way to properly close the ScrollableResult?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 13, 2007 3:11 am 
Beginner
Beginner

Joined: Fri Jan 27, 2006 4:20 am
Posts: 22
Also, if you revise the code above to the following lines:

Code:
      ScrollableResults sr = emSybase.getSession()
         .createQuery("from Audittrail2")
         .setReadOnly( true )
         .scroll( ScrollMode.SCROLL_INSENSITIVE );
      
      sr.next();
      sr.close();


It will hang your application.. (perhaps forever?)

When I paused the thread, you will see it is stuck on line 206:

Code:
200   public void closeQueryStatement(PreparedStatement ps, ResultSet rs) throws SQLException {
201      boolean psStillThere = statementsToClose.remove( ps );
202      try {
203         if ( rs != null ) {
204            if ( resultSetsToClose.remove( rs ) ) {
205               logCloseResults();
206               rs.close();
207            }
208         }
209      }


But using the pure JDBC like on the following lines I got no problems on closing the resultset unlike above code on line 206:

Code:
       try
       {
       Class.forName( "com.sybase.jdbc3.jdbc.SybDriver" );
       }
       catch (ClassNotFoundException e)
       {
       e.printStackTrace();
       }
      
       ResultSet rs = null;
       Connection con = null;
       Statement st = null;
      
       try
       {
          con = DriverManager.getConnection(
                "jdbc:sybase:Tds:stage.brokerhub.net:4100/SERVER",
                "sa",
                "close2come");
         
       st = con.createStatement( ResultSet.TYPE_FORWARD_ONLY,
       ResultSet.CONCUR_READ_ONLY );
       st.setCursorName( "myCursor" );
            
       rs = st.executeQuery("select * from AUDITTRAIL");
      
       rs.next();
      
       rs.close();
         
       }
       catch( SQLException e)
       {
          e.printStackTrace();
       }



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.