-->
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.  [ 3 posts ] 
Author Message
 Post subject: error when update data to a table with triger
PostPosted: Mon Dec 05, 2005 6:32 am 
Newbie

Joined: Mon Dec 05, 2005 6:16 am
Posts: 2
Location: Shenyang, Liaoning province, China
I was always caught by the error when updating data to a table which have a triger in it,
16:25:22,890 ERROR SessionImpl:2399 - Could not synchronize database state with session
net.sf.hibernate.HibernateException: SQL insert, update or delete failed (row not found)
at net.sf.hibernate.impl.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:25)
at net.sf.hibernate.persister.EntityPersister.update(EntityPersister.java:663)
at net.sf.hibernate.persister.EntityPersister.update(EntityPersister.java:623)
at net.sf.hibernate.impl.ScheduledUpdate.execute(ScheduledUpdate.java:52)
at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2438)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2392)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2260)
at net.sf.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:61)
at pal.pdm.personnel.base.HibernateExec.updateObjectWithTriger(HibernateExec.java:542)
at pal.pdm.personnel.MainClass.testUpdate(MainClass.java:135)
at pal.pdm.personnel.MainClass.main(MainClass.java:119)


I have tried to use method flush and refresh to solve it, but it failed
session.update(obj);
session.flush();
session.refresh(obj);
session.commit();

The triger is
CREATE TRIGGER [ORG_RESOURCE_update_for_prj] ON dbo.ORG_RESOURCE
FOR UPDATE
AS
DECLARE @old_dev_no as nvarchar(20),
@new_dev_no as nvarchar(20),
@dev_name as nvarchar(50),
@dev_type as nvarchar(256)
--get the old id
SELECT @old_dev_no=del.c_resourceno
FROM deleted del
--get the new id and name
SELECT
@new_dev_no=ins.c_resourceno,
@dev_name=ins.c_resourcename,
@dev_type=ins.c_type
FROM inserted ins
--update task info
UPDATE PRJ_TASKDEVICE SET
devno=@new_dev_no,
taskdevname=@dev_name,
devicetype=@dev_type
where devno=@old_dev_no

help me, thanks :)
I'm sorry, I'm a chinese with poor English
and for the first I come here
please be tolerant to my poor English


Top
 Profile  
 
 Post subject: Please, I'm waiting for your help
PostPosted: Mon Dec 05, 2005 11:56 am 
Newbie

Joined: Mon Dec 05, 2005 6:16 am
Posts: 2
Location: Shenyang, Liaoning province, China
the problem is the excpetion - Could not synchronize database state with session
just because I used a triger in the table that I wanted to update


Top
 Profile  
 
 Post subject: Update with trigger giving Could not synchronize database st
PostPosted: Thu May 04, 2006 2:04 pm 
Newbie

Joined: Thu May 04, 2006 1:59 pm
Posts: 1
Have you found a solution to this problem ?
I am facing the same issue.
I am trying to update a table which has triggers on it.

It gives me error.
04 May 10:50:03 ERROR def.AbstractFlushingEventListener:300 - Could not synchronize database state with session
org.hibernate.StaleStateException: Unexpected row count: 0 expected: 1

I am using SQServer database.


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