-->
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.  [ 1 post ] 
Author Message
 Post subject: hilo with JDBCTransaction doesn't work on oc4j and oracle8i
PostPosted: Fri Mar 12, 2004 2:43 pm 
Newbie

Joined: Thu Nov 27, 2003 6:53 pm
Posts: 2
Location: Vancouver Canada
hibernate version: 2.0.3
oracle8i
oc4j 9.0.3 standalone

the mapping file:
********************************************
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class
name="org.cgacanada.mes2.model.User"
table="M_USERS">
<id
name="userId"
column="user_id"
type="long">
<generator class="hilo">
<param name="table">hibernate_unique_key</param>
<param name="column">next_hi</param>
</generator>
</id>
<property name="name" column="name"/>
<property name="password" column="password"/>
<property name="title" column="title"/>
<property name="firstName" column="first_name"/>
<property name="lastName" column="last_name"/>
<property name="middleName" column="middle_name"/>
<property name="language" column="language"/>
<property name="active" column="is_active"/>
<property name="email" column="email"/>
<property name="description" column="description"/>
<property name="lastUpdatedDTS" column="last_updated_dts"/>
<property name="updatedByUser" column="updated_by_user"/>
</class>
</hibernate-mapping>
*******************************************

the code(before the code execution, a transaction already started):
private long createStudentUser( TBLC_CLIENT_COURSE_ENROLLMENT ccamsEnrollment, List ccamsPersonals,String currentUserName,net.sf.hibernate.Session hSession){

User newStudentUser = createNewUser(personalInfo);
newStudentUser.setName(String.valueOf(studentInternalId));
try{
studentUserIdLong = (Long) hSession.save(newStudentUser);
}catch(HibernateException he){
throw new ImportException(he,"create student user failed. Student number: "+studentNo);
}

return studentUserIdLong.longValue();
}
private User createNewUser(TBLC_CLIENT_PERSONAL ccamsPersonal) {
User user = new User();
user.setName("");
user.setTitle(ccamsPersonal.getTitle_code());
user.setPassword("");
user.setFirstName(ccamsPersonal.getFirst_name());
user.setLastName(ccamsPersonal.getLast_name());
user.setMiddleName(ccamsPersonal.getMiddle_name());
user.setLanguage("");
user.setActive(true);
user.setEmail("");
user.setDescription("Created from C-CAMS data. ");
user.setLastUpdatedDTS(new Date());
user.setUpdatedByUser(getCurrentUserName());
return user;
}
********************************************************

the hibernate.cfg.xml file:

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration
PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="connection.datasource">jdbc/MES2CoreDS</property>
<property name="show_sql">true</property>
<property name="dialect">net.sf.hibernate.dialect.OracleDialect</property>
<property name="use_outer_join">true</property>

<!--0-3 recommended -->
<property name="max_fetch_depth">1</property>
<property name="jdbc.fetch_size">20</property>
<property name="jdbc.batch_size">50</property>
<property name="jdbc.use_scrollable_resultset">true</property>
<property name="jdbc.use_streams_for_binary">true</property>
<property name="cglib.use_reflection_optimizer">true</property>
<property name="transaction.factory_class">net.sf.hibernate.transaction.JDBCTransactionFactory</property>
<!--
<property name="connection.isolation"></property>
-->
<!-- Mapping files -->
<mapping resource="model/User.hbm.xml"/>

......
......
</session-factory>
</hibernate-configuration>

*******************************************************

the trace:
TableGenerator ERROR - could not read a hi value
java.sql.SQLException: ORA-01002: fetch out of sequence

at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:187)
at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:241)
at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:543)
at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1477)
at oracle.jdbc.ttc7.TTC7Protocol.fetch(TTC7Protocol.java:969)
at oracle.jdbc.driver.OracleStatement.doExecuteQuery(OracleStatement.java:2362)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2635)
at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:452)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:382)
at net.sf.hibernate.id.TableGenerator.generate(TableGenerator.java:93)
at net.sf.hibernate.id.TableHiLoGenerator.generate(TableHiLoGenerator.java:59)
at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:727)
at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:717)
at org.cgacanada.mes2.dataimport.ImportManager.createStudentUser(ImportManager.java:715)
at org.cgacanada.mes2.dataimport.ImportManager.processStudent(ImportManager.java:528)
at org.cgacanada.mes2.dataimport.ImportManager.importEnrollments(ImportManager.java:138)
at org.cgacanada.mes2.actions.ImportEnrollmentsAction.perform(ImportEnrollmentsAction.java:58)
at org.apache.struts.action.ActionServlet.processActionPerform(ActionServlet.java:1788)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1586)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:492)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:721)
at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:306)
at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:767)
at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:259)
at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:106)
at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:803)
at java.lang.Thread.run(Thread.java:536)
JDBCExceptionReporter WARN - SQL Error: 1002, SQLState: 72000
JDBCExceptionReporter ERROR - ORA-01002: fetch out of sequence

JDBCException ERROR - Could not save object
java.sql.SQLException: ORA-01002: fetch out of sequence

at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:187)
at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:241)
at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:543)
at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1477)
at oracle.jdbc.ttc7.TTC7Protocol.fetch(TTC7Protocol.java:969)
at oracle.jdbc.driver.OracleStatement.doExecuteQuery(OracleStatement.java:2362)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2635)
at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:452)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:382)
at net.sf.hibernate.id.TableGenerator.generate(TableGenerator.java:93)
at net.sf.hibernate.id.TableHiLoGenerator.generate(TableHiLoGenerator.java:59)
at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:727)
at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:717)
at org.cgacanada.mes2.dataimport.ImportManager.createStudentUser(ImportManager.java:715)
at org.cgacanada.mes2.dataimport.ImportManager.processStudent(ImportManager.java:528)
at org.cgacanada.mes2.dataimport.ImportManager.importEnrollments(ImportManager.java:138)
at org.cgacanada.mes2.actions.ImportEnrollmentsAction.perform(ImportEnrollmentsAction.java:58)
at org.apache.struts.action.ActionServlet.processActionPerform(ActionServlet.java:1788)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1586)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:492)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:721)
at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:306)
at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:767)
at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:259)
at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:106)
at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:803)
at java.lang.Thread.run(Thread.java:536)
*************************************************

the application used to use hibernate connection pool confured in hibernate.properties file to process data and use a oc4j datasourse to do the container managed authentication. that means we have to mainain two connection pool for the application. the bad thing is the configuration for the hibernate connection pool can not be changed on the fly after deployment unless recompilation and re-deployment.
so now i am trying to only use oc4j connection pool to process data. I recognized that the hilo can not working with JTATransaction, so I set
<property name="transaction.factory_class">net.sf.hibernate.transaction.JDBCTransactionFactory</property>
in the hibernate.cfg.xml file. But I still get the exception.

I am wondering if I set wrong trasaction type or hilo can not work in nested transaction even with JDBCTransaction?

There number of entities using hilo to generate keys, so It's not so simple to change them to sequence or other key generators.

Any help will be appreciated.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.