-->
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.  [ 6 posts ] 
Author Message
 Post subject: scrollable result sets are not enabled
PostPosted: Tue May 20, 2008 11:24 am 
Newbie

Joined: Tue May 20, 2008 10:32 am
Posts: 1
We have production code running for some time now. Yesterday, we suddenly received the following error:

2008-05-19 09:17:03,901 ERROR [org.hibernate.AssertionFailure] an assertion failure occured (this may indicate a bug in Hibernate, but is more likely due to unsafe use of the session)
org.hibernate.AssertionFailure: scrollable result sets are not enabled
at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:475)
at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:423)
at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:139)
at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1547)
at org.hibernate.loader.Loader.scroll(Loader.java:2285)
at org.hibernate.loader.criteria.CriteriaLoader.scroll(CriteriaLoader.java:89)
at org.hibernate.impl.SessionImpl.scroll(SessionImpl.java:1533)
at org.hibernate.impl.CriteriaImpl.scroll(CriteriaImpl.java:297)

We use a slight modified version of paginationCode (http://www.hibernate.org/248.html) with Criteria instead of query

The issue went away after we restarted Tomcat (5.0.28).

Using Hibernate version: 3.2.6ga with the following properties:

<property name="dialect">org.hibernate.dialect.Oracle10gDialect</property>
<property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="org.hibernate.cache.CacheProvider">
net.sf.ehcache.hibernate.EhCacheProvider
</property>
<property name="hibernate.cache.use_second_level_cache">false</property>
<property name="hibernate.cache.use_query_cache">false</property>
<property name="current_session_context_class">thread</property>
<property name="bytecode.use_reflection_optimizer">true</property>

Because this rarely happens and we aren't unable to recreate the problem, we would like community feedback on what to watch out for in preventing the problem from reappearing. Thanks.


Top
 Profile  
 
 Post subject: Re: scrollable result sets are not enabled
PostPosted: Sun Mar 27, 2011 12:48 pm 
Beginner
Beginner

Joined: Thu Jun 21, 2007 1:47 pm
Posts: 46
Just recently hacing the same issue, has anyone figured out the cause? Restarting the server can fix the issue ... or bring it back. How does hibernate check for support for scrollable result sets? Could it be a timing issue with the database? Could c3p0 be to blame?

We're using Hibernate with PostgreSQL and a c3p0 connection pool.


Top
 Profile  
 
 Post subject: Re: scrollable result sets are not enabled
PostPosted: Sun Mar 27, 2011 12:52 pm 
Beginner
Beginner

Joined: Thu Jun 21, 2007 1:47 pm
Posts: 46
Looking at the code, it seems likely that if hibernate fails to connect to the database during startup, or the JDBC driver doesn't have enough information to answer its questions about capabilities, the support for scrollable result sets would default to "off".


Top
 Profile  
 
 Post subject: Re: scrollable result sets are not enabled
PostPosted: Sun Mar 27, 2011 12:57 pm 
Beginner
Beginner

Joined: Thu Jun 21, 2007 1:47 pm
Posts: 46
It looks like setting `hibernate.jdbc.use_scrollable_resultset = true` might prevent this error.

See `org.hibernate.cfg.SettingsFactory.buildSettings(Properties)`.

I do think, however, that if hibernate is relying on a database connection to gather this critical data, it should not fail quietly if the database is not present, as it may result in a less reliable server in case things are being restarted automatically.


Top
 Profile  
 
 Post subject: Re: scrollable result sets are not enabled
PostPosted: Sun Mar 27, 2011 6:19 pm 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Hibernate does not fail quietly if it cannot connect to the database. However, scrollable results are an optional feature, so it's fine to create a connection without enabling them, as long as you won't use them.
The bug if any is that it produces (in this very old version) an Assertion Error, it would likely be easier to understand as configuration error.

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
 Post subject: Re: scrollable result sets are not enabled
PostPosted: Tue Sep 13, 2011 9:40 am 
Beginner
Beginner

Joined: Fri May 12, 2006 9:58 am
Posts: 32
Yes, setting hibernate.jdbc.use_scrollable_resultset to true does solve this problem. Thanks a lot.

My specific use case was on a server which when rebooted:
1) mysql reports started
2) tomcat starts (service depends on mysql)
3) mysql detects:
Code:
InnoDB: The log sequence number in ibdata files does not match
InnoDB: Database was not shut down normally!
InnoDB: Starting crash recovery.

4) tomcat starts application which on startup attempts to connect to the database but cannot get connection, so I get:
Code:
WARN (SettingsFactory.java:..) - Could not obtain connection to query metadata
...
INFO  (SettingsFactory.java:..) - Scrollable result sets: disabled

5) mysql finishes recovery after half a minute and reports: ready for connections
6) c3p0 managed connection from my application finally gets a connection and application runs correctly apart when it needs to do a scrollable query where I get the:
Code:
org.hibernate.AssertionFailure: scrollable result sets are not enabled


Setting this option to true makes my application start with:
Code:
(SettingsFactory.java:..) Scrollable result sets: enabled

no matter whether a datasource is available or not.


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