-->
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: Synchronization problem with database and session
PostPosted: Thu Sep 09, 2004 6:24 am 
Newbie

Joined: Sun Apr 18, 2004 2:29 am
Posts: 18
hi
i got stuck with this problem. i have throughly examined my code but cant understand where is the problem.at the time of saving the object it is giving an invalid characte exception and a could not synchronize with the databe exception.i suppose the problem could be with the association with other objects .i have there other object reference with the saving object.
i have tried different ways to solve it.but couldnt.

please help me.

Regards Shamim

Hibernate version:2.1

Mapping documents:
<class name="com.diit.voffice.payroll.overtime.OvertimeApprovalProcessDto" table="overtime_app_process">

<id name="pkCode" column="PK_CODE">
<generator class="assigned"/>
</id>

<many-to-one name="overtimeInfo" column="ot_f_code"/>
<many-to-one name="sendingEmployee" column="s_emp_f_code"/>
<many-to-one name="receiveEmployee" column="r_emp_f _code"/>
<property name="sendingPosition" column="s_pos"/>
<property name="sendingDateType" column="s_date" type="date"/>
<property name="sendingStatement" column="s_state"/>
<property name="receivePosition" column="r_pos"/>
<property name="receiveStatus" column="r_status"/>
<property name="processDateType" column="pro_date" type="date"/>
<property name="processStatement" column="pro_state"/>
</class>


Code between sessionFactory.openSession() and session.close():
public void testPrepareProcess() throws Exception {
Session session = factory.openSession(pool.getConnection());
ovAppProcess = new OvertimeApprovalProcessDto();

ovAppProcess.setPkCode("1");
log.debug("PkCode:" + ovAppProcess.getPkCode());

ovAppProcess.getOvertimeInfo().setPkCode("1");
ovAppProcess.getSendingEmployee().setPkCode("1");
ovAppProcess.getReceiveEmployee().setPkCode("1");

ovAppProcess.setSendingPosition(KeyConstants.BONUS_PROCESS_TIER1);
ovAppProcess.setSendingDateType(new Date(2002, 8, 10));
ovAppProcess.setSendingStatement("Successfully overtime calculated");
ovAppProcess.setReceivePosition(KeyConstants.BONUS_PROCESS_TIER2);
ovAppProcess.setReceiveStatus(KeyConstants.BONUS_PROCESS_STATUS_PREPARE);

log.debug("Pk Code : " + ovAppProcess.getPkCode());
log.debug("OT F CODE : " + ovAppProcess.getOvertimeInfo());
log.debug("S_EMP F CODE : " + ovAppProcess.getSendingEmployee());
log.debug("S_POS : " + ovAppProcess.getSendingPosition());
log.debug("S_DATE : " + ovAppProcess.getSendingDateType());
log.debug("S_STATE : " + ovAppProcess.getSendingStatement());
log.debug("R_EMP F CODE : " + ovAppProcess.getReceiveEmployee());
log.debug("R_POS : " + ovAppProcess.getReceivePosition());
log.debug("R_STATUS : " + ovAppProcess.getReceiveStatus());

result.setSuccess();
result.setActionMessage("message.saved.success");

session.save(ovAppProcess);
session.flush();
session.connection().commit();

log.debug("Result:" + result);
}


Full stack trace of any exception that occurs:
2004-09-09 16:11:55,453 ERROR [main] impl.SessionImpl (SessionImpl.java:2269) - Could not synchronize database state with session
net.sf.hibernate.JDBCException: could not insert: [com.diit.voffice.payroll.overtime.OvertimeApprovalProcessDto#1]
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:479)
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:443)
at net.sf.hibernate.impl.ScheduledInsertion.execute(ScheduledInsertion.java:29)
at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2308)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2261)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2187)
at com.diit.voffice.payroll.bonus.TestPrepareOvertimeApprovalProcess.testPrepareProcess(TestPrepareOvertimeApprovalProcess.java:132)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:395)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:279)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:171)
Caused by: java.sql.SQLException: ORA-00911: invalid character

at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:180)
at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:208)
at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:543)
at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1451)
at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:862)
at oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:1846)
at oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:1771)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2361)
at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:422)
at net.sf.hibernate.impl.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:22)
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:469)
... 21 more

Name and version of the database you are using:oracle9

Debug level Hibernate log excerpt:


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 09, 2004 8:09 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
Quote:
ovAppProcess.getOvertimeInfo().setPkCode("1");
ovAppProcess.getSendingEmployee().setPkCode("1");
ovAppProcess.getReceiveEmployee().setPkCode("1");


what is this? sounds strange,
give the other mapping files

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 09, 2004 8:27 am 
Newbie

Joined: Sun Apr 18, 2004 2:29 am
Posts: 18
ovAppProcess.getOvertimeInfo().setPkCode("1");
ovAppProcess.getSendingEmployee().setPkCode("1");
ovAppProcess.getReceiveEmployee().setPkCode("1");

i cant understand why the above code seems strange.i am setting the association.

The following is the mapping document of the other two persistence classes--

<class name="com.diit.voffice.payroll.overtime.OvertimeInformationDto" table="overtime_info">

<id name="pkCode" column="PK_CODE">
<generator class="assigned"/>
</id>
<many-to-one name="employee" column="emp_f_code" not-null="true"/>
<many-to-one name="prepareEmployee" column="prp_emp_f_code"/>
<property name="periodFromType" column="period_from" type="date"/>
<property name="periodToType" column="period_to" type="date"/>
<property name="duration" column="ot_duration"/>
<property name="approvalStatus" column="app_status"/>
<property name="tierPosition" column="tier_pos"/>
<property name="userName" column="USER_ID" not-null="true"/>
<property name="userDateType" column="USER_DATE" type="date"/>
</class>


<class name="com.diit.voffice.eis.emp.EmployeeDto" table="emp_info">

<id name="pkCode" column="PK_CODE">
<generator class="assigned"/>
</id>
<many-to-one name="entity" column="EMP_ENT_CODE"/>
<property name="empCode" column="EMP_CODE"/>
<property name="passportNumber" column="PP_NUMBER"/>
<many-to-one name="passportCountry" column="PP_CNT_CODE"/>
<property name="passportExpireDateType" column="PP_EXP_DATE" type="date"/>
<property name="tribal" column="TRIBAL"/>
<property name="freedomFighter" column="FREEDOM_F"/>
<property name="drivingLicense" column="DRIVE_LSN"/>
<property name="drivingLicenseNo" column="DRIVE_LSN_NO"/>
<property name="drivingLicenseExpireDateType" column="DL_EXP_DATE"/>
<property name="photo" column="PHOTO_PATH"/>
<property name="signature" column="SIGN_PATH"/>
<property name="status" column="STATUS"/>
<property name="foreignEmployee" column="FOREIGN_EMP"/>
<property name="transferableJob" column="TRANSFER_JOB"/>
<property name="notes" column="NOTES"/>
<property name="userId" column="USER_ID" not-null="true"/>
<property name="userDateType" column="USER_DATE" type="date"/>

</class>


The following is the code of the persistent classes

public class OvertimeApprovalProcessDto implements Serializable, Cloneable {

private String _pkCode;
private OvertimeInformationDto _overtimeInfo;
private EmployeeDto _sendingEmployee;
private EmployeeDto _receiveEmployee;
private String _sendingPosition;
private String _sendingDate;
private Date _sendingDateType;
private String _sendingStatement;
private String _receivePosition;
private String _receiveStatus;
private String _processDate;
private Date _processDateType;
private String _processStatement;
private Collection _processList;

public OvertimeApprovalProcessDto() {
super();
// TODO Auto-generated constructor stub
_overtimeInfo = new OvertimeInformationDto();
_sendingEmployee = new EmployeeDto();
_receiveEmployee = new EmployeeDto();
}


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 09, 2004 8:29 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
ovAppProcess.getOvertimeInfo().setPkCode("1");
ovAppProcess.getSendingEmployee().setPkCode("1");
ovAppProcess.getReceiveEmployee().setPkCode("1");


should be
ovAppProcess.setOvertimeInfo(object)....

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 09, 2004 8:38 am 
Newbie

Joined: Sun Apr 18, 2004 2:29 am
Posts: 18
i tried with that.but the same exception was thrown.i thought the hibernate is trying to insert the object itself instead of taking the id field.thats why i set the id property of the nested object manually.

i am working with hibernate for several months.and i was working in the way u suggested.there was not any problem.but this time exception was thrown.i cant understand it.please give me some suggestion

Shamim


Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 11, 2004 2:24 am 
Newbie

Joined: Sun Apr 18, 2004 2:29 am
Posts: 18
i have solved the problem.there was a mapping problem.a space was mistakenly inserted into the following column name.

<many-to-one name="receiveEmployee" column="r_emp_f _code"/>

thanks Anthony for quick responses

regards
Shamim


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.