-->
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: Update on version column even if nothing has changed
PostPosted: Mon Jan 24, 2011 8:03 am 
Regular
Regular

Joined: Wed Sep 21, 2005 1:37 pm
Posts: 53
Location: Montpellier - France
Hi all,

I have detected a strange behavior when updating some entities. The version column is updated even if nothing has changed on entity and some associated entities are updated to (version column) even if no cascading is specified.

Hibernate: 3.1.5-Final

Part of the code:

Code:
@Entity(name = "A")
@org.hibernate.annotations.Entity(dynamicUpdate = true, selectBeforeUpdate = true, optimisticLock = OptimisticLockType.VERSION)
@Table(name = "A")
public class ABean {
...
@Version
@Column(name = MODIFICATION_DATE, nullable = false)
@Type(type = "DateTimeUserType")
public DateTime getModificationDate() {
   return modificationDate;
}
..
@JoinColumn(name = "bid", referencedColumnName = "bid", nullable = true)
@ManyToOne(targetEntity =BBean.class, fetch = FetchType.LAZY)
@ForeignKey(name = "FK_A_B")
public BBean getCategory() {
   return category;
}
...
}


In logs, I can see:
[SQL ] update A set modificationDate=? where key=? and modificationDate=?
[SQL ] update B set modificationDate=? where key=? and modificationDate=?

No collection is updated in A or B and I really don't understand why hibernate invokes the update for the version column.

Thanks


Top
 Profile  
 
 Post subject: Re: Update on version column even if nothing has changed
PostPosted: Mon Jan 24, 2011 9:42 am 
Regular
Regular

Joined: Wed Sep 21, 2005 1:37 pm
Posts: 53
Location: Montpellier - France
I have added the 'selectBeforeUpdate=true' for the entities and it resolves the issue on most cases but not on all.


Top
 Profile  
 
 Post subject: Re: Update on version column even if nothing has changed
PostPosted: Sat Jan 29, 2011 4:59 pm 
Regular
Regular

Joined: Wed Sep 21, 2005 1:37 pm
Posts: 53
Location: Montpellier - France
Hi,

No idea regarding this issue ? Why does hibernate update only the version column for an entity defining these persistence properties ?

@org.hibernate.annotations.Entity(dynamicUpdate = true, selectBeforeUpdate = true, dynamicInsert = true,

Query seen in logs:

update
A
set
modificationDate=?
where
aid=?
and modificationDate=?


Thanks.


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.