-->
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: staleobject exception
PostPosted: Tue Jul 27, 2010 11:05 am 
Newbie

Joined: Tue Jul 27, 2010 10:15 am
Posts: 3
Hi there,

We are developing an internal application using Netbeans 6.5 and Hibernate version 3.2.5, the application has two tables which need to be updated as soon a user click submit. Both the tables have Primary Composite Keys set amongst each other. Below is the table structure and the hbm file and the error message . What ideally would need to happen is once the submit is clicked TBLTRAINEE_FBK_MASTER would add a new record and TBLTRAINEE would have FBK_STATUS updated for a trainee. There is more table TBLBATCH which has however 1 to M relationship with TBLTRAINEE, it is used merely to obtain TRAINEE List. What we feel is that there is something that locks the TRAINEE Oject thereby not letting it proceed updation on TBLTrainee. Please refer the last section for Error Message.

Please advise and guide as to what could be possibly wrong

*******TABLE DDL**************

CREATE TABLE VNAUSER .TBLBATCH (
BATCH_CODE VARCHAR(40) NOT NULL ,
BATCH_TYPE VARCHAR(5) ,
TRAINER_ECODE VARCHAR(20) ) ;
ALTER TABLE VNAUSER .TBLBATCH ADD CONSTRAINT TBLBATCH_PK PRIMARY KEY(BATCH_CODE);

CREATE TABLE VNAUSER .TBLTRAINEE (
TRAINEE_APPLICANT_ID VARCHAR(20) NOT NULL ,
BATCH_CODE VARCHAR(40) NOT NULL ,
FBK_STATUS VARCHAR(20));
ALTER TABLE VNAUSER .TBLTRAINEE ADD CONSTRAINT TBLTRAINEE_PK PRIMARY KEY (TRAINEE_APPLICANT_ID, BATCH_CODE);


CREATE TABLE VNAUSER .TBLTRAINEE_FBK_MASTER (
TRAINEE_APPLICANT_ID VARCHAR(10) NOT NULL ,
BATCH_CODE VARCHAR(20) NOT NULL ,
TRAINER_ECODE VARCHAR(10) ,
TRAINEE_ECODE VARCHAR(10));

ALTER TABLE VNAUSER .TBLTRAINEE_FBK_MASTER ADD CONSTRAINT TBLTRAPK PRIMARY KEY(BATCH_CODE, TRAINEE_APPLICANT_ID);

----- HBM FILE TRAINEE ---------------

<!-- Generated Jul 15, 2010 8:06:47 PM by Hibernate Tools 3.2.1.GA -->
<hibernate-mapping>
<class lazy="true" name="com.ibm.vma.beans.Tbltrainee" schema="VNAUSER" table="TBLTRAINEE">
<composite-id class="com.ibm.vma.beans.TbltraineeId" name="id">
<key-property name="traineeApplicantId" type="string">
<column length="20" name="TRAINEE_APPLICANT_ID"/>
</key-property>
<key-property name="batchCode" type="string">
<column length="40" name="BATCH_CODE"/>
</key-property>
</composite-id>
<timestamp column="TIMESTAMP" name="timestamp"/>
<many-to-one class="com.ibm.vma.beans.Tblbatch" fetch="select" insert="false" name="tblbatch" update="false">
<column length="40" name="BATCH_CODE" not-null="true"/>
</many-to-one>
<property name="fbkStatus" type="string">
<column length="20" name="FBK_STATUS"/>
</property>
</class>
</hibernate-mapping>

----- HBM FILE TRAINEE FEEDBACK MASTER -----------

"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated Jul 16, 2010 5:05:19 PM by Hibernate Tools 3.2.1.GA -->
<hibernate-mapping>
<class name="com.ibm.vma.beans.TbltraineeFbkMaster" schema="VNAUSER" table="TBLTRAINEE_FBK_MASTER">
<composite-id class="com.ibm.vma.beans.TbltraineeFbkMasterId" name="id">
<key-property name="batchCode" type="string">
<column length="20" name="BATCH_CODE"/>
</key-property>
<key-property name="traineeApplicantId" type="string">
<column length="10" name="TRAINEE_APPLICANT_ID"/>
</key-property>
</composite-id>
<property name="trainerEcode" type="string">
<column length="10" name="TRAINER_ECODE"/>
</property>
<property name="traineeEcode" type="string">
<column length="10" name="TRAINEE_ECODE"/>
</class>
</hibernate-mapping>

----- HBM FILE TABLE BATCH -----------

<!-- Generated Jul 26, 2010 6:43:26 PM by Hibernate Tools 3.2.1.GA -->
<hibernate-mapping>
<class name="com.ibm.vma.beans.Tblbatch" schema="VNAUSER" table="TBLBATCH">
<id name="batchCode" type="string">
<column length="40" name="BATCH_CODE"/>
<generator class="assigned"/>
</id>
<timestamp column="TIMESTAMP" name="timestamp"/>
<property name="batchType" type="string">
<column length="5" name="BATCH_TYPE"/>
</property>
<property name="trainerEcode" type="string">
<column length="20" name="TRAINER_ECODE"/>
</property>
<set inverse="true" lazy="true" name="tbltrainees">
<key>
<column length="40" name="BATCH_CODE" not-null="true"/>
</key>
<one-to-many class="com.ibm.vma.beans.Tbltrainee" />
</set>
</class>
</hibernate-mapping>

********* ERROR MESSAGE ON UPDATION OF TRAINEE TABLE************


org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [com.ibm.vma.beans.Tblbatch#NHT-MUM-16012010]
at org.hibernate.persister.entity.AbstractEntityPersister.check(AbstractEntityPersister.java:1765)
at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2407)
at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2307)
at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2607)
at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:92)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:250)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:234)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:142)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)

regards
Abdul


Top
 Profile  
 
 Post subject: Re: staleobject exception
PostPosted: Wed Jul 28, 2010 12:23 pm 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
please post in the correct forum

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


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.