-->
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: Timestamp field: update problem
PostPosted: Wed Aug 29, 2007 2:48 pm 
Newbie

Joined: Wed Aug 29, 2007 2:45 pm
Posts: 2
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?


Top
 Profile  
 
 Post subject: I've taken over this!!
PostPosted: Wed Aug 29, 2007 5:04 pm 
Newbie

Joined: Wed Aug 29, 2007 2:45 pm
Posts: 2
Yep! I've sort this problem out by myself.
The reason was the Time zone of virtal mashine. It deffers from the time zone of the database. The solution was to set the timezone:
TimeZone.setDefault(TimeZone.getTimeZone("GMT-7"));


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.