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