-->
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: Issues persisting (updating) and entity
PostPosted: Wed May 10, 2006 11:00 am 
Newbie

Joined: Fri Apr 28, 2006 1:48 pm
Posts: 7
I have a legacy database and each table has create_ts, update_ts columns populated via triggers. I ran into trouble with hibernate when wanted to update some rows and persistence manager treated detached object as transient, as result Hibernate inserted another row when I would have expected an update.

Below is an example of the mapping file and please note that I have changed the <Sql-update> generated command. Any thoughts?

Thanks,
valy

<hibernate-mapping>
<class name="org.ifm.model.Person"
table="Persons"
dynamic-insert="true"
dynamic-update="false"
select-before-update="true">

<id name="indi" type ="long"
column="INDI"
unsaved-value="0">
<generator class="sequence">
<param name="sequence">indi_seq</param>
</generator>
</id>

<timestamp
column="UPDATE_TS"
name="UpdateTs"
access="property"
source="db"
generated="always"
unsaved-value="undefined"/>

<property
name="firstName"
type="java.lang.String"
column="FIRST_NAME"
not-null="true"
length="30"/>

<property
name="lastName"
type="java.lang.String"
column="LAST_NAME"
not-null="true"
length="30"/>

<sql-update>
UPDATE persons
SET first_name=?,
last_name=?
WHERE indi=?
AND (indi_update_ts IS NULL OR indi_update_ts=?)
</sql-update>

</class>
</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 10, 2006 5:45 pm 
Newbie

Joined: Fri Apr 28, 2006 1:48 pm
Posts: 7
Never mind, I have solved the issue usiing Hibernate Interceptors.

Best Regards,
Valy


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.