Hibernate version:
Hi, I'm using Hibernate 3.1.3 with annotations on Oracle 9i. I have thoroughly found with no success in the forum and the Internet before submitting this post.
The problem I have is that when I persist a Date or Timestamp (I tried both) the database value is (exactly) 2 hours off. The way this is carrying out is really rare since I have indicated Hibernate neither to insert nor update this field. I want this field to be filled by the database automatically by setting the default value which turned to be CURRENT_TIMESTAMP.
The following Java snippet corresponds to the field causing this problem:
Code:
@Entity
@org.hibernate.annotations.Entity( dynamicUpdate = true )
@Table( name = "REQUEST_HISTORY", uniqueConstraints = {})
@SequenceGenerator( name="SEQ_GEN", sequenceName="SEQ_REQUEST_HISTORY" )
public class Request implements java.io.Serializable
{
....
private Date creation; // Also tried as java.sql.Timestamp
.....
@Column( name = "CREATION", unique = false, nullable = false, insertable = false, updatable = false, length = 6 )
@Temporal( TemporalType.DATE )
public Date getArrivingTime()
{
return this.creation;
}
protected void setArrivingTime( Date creation )
{
this.creation = creation;
}
.....
The database DLL for this field is:
Code:
Column name Null? Data type Default
----------------------------------------------------------------------------
CREATION Not null TIMESTAMP(6) CURRENT_TIMESTAMP
The Hibernate SQL log ( show_sql = true ):
Code:
Hibernate: select SIM_TB.SEQ_REQUEST_HISTORY.nextval from dual
Hibernate: insert into SIM_TB.REQUEST_HISTORY (STATE, TYPE, SHOWING_ID, DEDICATION, USER_ID, PLAYED, REQUEST_ID) values (?, ?, ?, ?, ?, ?, ?)
Hibernate: update SIM_TB.REQUEST_HISTORY set STATE=?, TYPE=?, SHOWING_ID=?, DEDICATION=?, USER_ID=?, PLAYED=? where REQUEST_ID=?
As you can see this field shouldn't be involed in any write-operation done by Hibernate. Thus, I don't undertand why if do an insert by hand, the value is properly created (the DB date and time are fine) while using Hibernate the problem araises.
Do you have any idea of what might be happening here?
I live in Europe while the NLS_TERRITORY value of the DB is AMERICA. Could this affect in any way?
Any help you could provide would be really appreciated.
Thanks for your time! :)