Ok, here is what I'm seeing.
Here is the mapping for this property (generated by xdoclet).
Code:
<property
name="lastUpdated"
type="timestamp"
update="true"
insert="true"
access="property"
column="lastUpdated"
not-null="true"
/>
here is the full code (it's a java.util.Date):
Code:
private Date lastUpdated = new Date();
/**
* @hibernate.property
* type = "timestamp"
* not-null = "true"
*/
public Date getLastUpdated()
{
return lastUpdated;
}
public void setLastUpdated(Date lastUpdated)
{
this.lastUpdated = new Date(lastUpdated.getTime());
}
If I retrieve this object in a new session (not the one it was saved in) and I don't modify it, Hibernate is (incorrectly) issuing an UPDATE when I commit the transaction.
If I change the setter like the following then there is no UPDATE (as expected).
Code:
public void setLastUpdated(Date lastUpdated)
{
this.lastUpdated = lastUpdate;
}
That's the only change I make.
The UPDATE should not be happening.
I'm I doing something wrong?