I'm using hibernate 3.2.1.ga and got stuck with the problem:
value of the field of type Timestamp changes during update.
The mapping is
<class name="misprint.model.DomainExpired" proxy="misprint.model.DomainExpired" table="mpDomainExpired">
<cache usage="nonstrict-read-write"/>
<id column="domainExpiredId" name="id" type="java.lang.String" unsaved-value="null">
<generator class="uuid.hex"/>
</id>
<property column="domainExpiredAccessDate" not-null="false" name="accessDate" type="java.sql.Timestamp" unique="false"/>
<property column="domainExpiredExpireDate" not-null="false" name="expiredDate" type="java.sql.Timestamp" unique="false"/>
...
</class>
The DomainExpired class:
public class DomainExpired extends DomainMissprint {
private String id;
private Timestamp expiredDate;
private Timestamp accessDate;
....
}
And I have a function
public void updateDomain(Domain d) throws SNException {
d.setAccessDate(new Timestamp(new Date().getTime()));
hu.updateObject(d);
}
hu.updateObject code:
public void updateObject(Model obj) throws SNException {
try {
Session sess = DBResource.getInstance().getSessionFactory().openSession();
Transaction tx = sess.beginTransaction();
try {
sess.update(obj);
tx.commit();
} catch (Exception e) {
tx.rollback();
throw new SNException(e);
} finally {
sess.close();
}
} catch (Exception e) {
throw new SNException(e);
}
}
When I run updateDomain, the value of d.expiredDate is being
changed (It is decreased by 1 day).
Before call of updateDomain() d.expiredDate == '20.06.2007', after
call it becomes '19.06.2007'.
Problem doesn't occurs each time. Any ideas?
|