Hibernate Books

All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: ORA-01002: fetch out of sequence
PostPosted: Fri Feb 15, 2008 12:33 am 
Newbie

Joined: Fri Feb 15, 2008 12:27 am
Posts: 3
Location: Jaipur
I am using these hibernate settings

<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.Oracle9Dialect
</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.format_sql">true</prop>
<prop key="hibernate.generate_statistics">true</prop>
<prop key="hibernate.use_outer_join">true</prop>
<prop key="hibernate.jdbc.batch_size">0</prop>
<prop key="hibernate.jdbc.use_streams_for_binary">
true
</prop>
<prop key="hibernate.max_fetch_depth">1</prop>
<prop key="hibernate.cache.use_second_level_cache">
true
</prop>
<prop key="hibernate.cache.use_query_cache">true</prop>
<prop key="hibernate.cache.provider_class">
org.hibernate.cache.EhCacheProvider
</prop>
<!-- <prop key="hibernate.query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory</prop> -->
<prop key="hibernate.query.factory_class">
org.hibernate.hql.ast.ASTQueryTranslatorFactory
</prop>

<prop key="hibernate.connection.release_mode">
auto
</prop>


</props>
</property>




When i execute a select query it shows following error:


ORA-01002: fetch out of sequence


Kindly tell me what should i do to resolve this problem.
what hibernate property should be changed in order to solve this.


Thanks in advance
[/b]


Top
 Profile  
 
 Post subject: ORA-01002: fetch out of sequence
PostPosted: Fri Jul 11, 2008 10:42 am 
Newbie

Joined: Fri Jul 11, 2008 10:09 am
Posts: 2
We are also experiencing the "ORA-01002: fetch out of sequence" problem with Hibernate 3 running with Liferay portal.

This is a critical problem for us. Every help is greatly appreciated.

This is the jboss datasource we're using:

<?xml version="1.0"?>

<datasources>
<local-tx-datasource>
<jndi-name>jdbc/LiferayPool</jndi-name>
<connection-url>jdbc:oracle:oci8:@lportal</connection-url>
<connection-property name="auto-commit">false</connection-property>
<driver-class>oracle.jdbc.OracleDriver</driver-class>
<user-name>****</user-name>
<password>****</password>
<min-pool-size>5</min-pool-size>
</local-tx-datasource>
</datasources>

and there are hibernate settings:

hibernate.cache.use_query_cache=true
hibernate.cache.use_second_level_cache=true
hibernate.cache.use_minimal_puts=true
hibernate.cache.use_structured_entries=false
#hibernate.cache.provider_class=org.hibernate.cache.NoCacheProvider
#hibernate.cache.use_query_cache=false
#hibernate.cache.use_second_level_cache=false

hibernate.jdbc.use_scrollable_resultset=true
hibernate.bytecode.use_reflection_optimizer=true
hibernate.show_sql=false


Thank you


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jul 12, 2008 10:25 am 
Beginner
Beginner

Joined: Tue Aug 26, 2003 2:46 pm
Posts: 45
Location: Saskatoon SK Canada
According to the Oracle documentation:

Quote:
ORA-01002: fetch out of sequence

Cause: This error means that a fetch has been attempted from a cursor which is no longer valid. Note that a PL/SQL cursor loop implicitly does fetches, and thus may also cause this error. There are a number of possible causes for this error, including: 1) Fetching from a cursor after the last row has been retrieved and the ORA-1403 error returned. 2) If the cursor has been opened with the FOR UPDATE clause, fetching after a COMMIT has been issued will return the error. 3) Rebinding any placeholders in the SQL statement, then issuing a fetch before reexecuting the statement.

Action: 1) Do not issue a fetch statement after the last row has been retrieved - there are no more rows to fetch. 2) Do not issue a COMMIT inside a fetch loop for a cursor that has been opened FOR UPDATE. 3) Reexecute the statement after rebinding, then attempt to fetch again.
[/quote]

I'm not sure whether it is your code or Hibernate that is to blame, but what I would do is turn on the SQL and transaction logging and see exactly what sequence of SQL and transaction begin/end statements is causing the problem.

_________________
Maury


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 14, 2008 10:48 am 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
Do a small query and see if you are searching past the last record in the returned list. If this is the case, the suggested solution should work!

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 15, 2008 7:32 am 
Newbie

Joined: Fri Jul 11, 2008 10:09 am
Posts: 2
After enabling Hibernate log and DB trace, we noticed 2 records missing in the DB, and it seems that this caused the problem.
So, for now, I would say that the problem isn't related to hibernate.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 16, 2008 5:46 am 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
I've also seen this caused by people looping through a ref cursor that is being used as an out parameter in the code. Instead, you can avoid the ORA-01002: Fetch Out Of Sequence Exception by opening two different and separate database cursors, and use one as the out parameter, and use the other cursor throughout the loop.

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 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.