Hi
I apologize if this question has been answered already. I posted this wrongly in the Tools forum and rightly got no response so I'm hoping I get some help here.
I am running an Oracle 9i database and using a 10G driver - ojdbc14_10-2-0-3.jar (copied to lib folder) , we are upgrading our database to 10G soon.
All my tables have timestamp columns for audit purposes.
Code:
CREATE TABLE CATALOG
(
CATALOG_ID INTEGER NOT NULL,
CATALOG_NAME VARCHAR2(50 BYTE) NOT NULL,
DATE_CREATED TIMESTAMP(6) DEFAULT systimestamp NOT NULL,
ADDED_BY INTEGER NOT NULL,
DATE_MODIFIED TIMESTAMP(6) DEFAULT systimestamp NOT NULL,
MODIFIED_BY INTEGER NOT NULL,
ENABLED CHAR(1 BYTE) DEFAULT 'N' NOT NULL,
VERSION_ID INTEGER DEFAULT 1 NOT NULL
);
After reverse engineering using Hibernate Tools,
the generated code maps my timestamp columns to Serializable
Code:
@Column(name = "DATE_CREATED", nullable = false)
@NotNull
public Serializable getDateCreated() {
return this.dateCreated;
}
So I then modified my timestamp fields to Date datatype in my Oracle table and mapped it as
Code:
@Temporal(TemporalType.DATE)
@Column(name = "DATE_CREATED", nullable = false)
@NotNull
public Date getDateCreated() {
return this.dateCreated;
}
The problem with this mapping was that Hibernate strips off time after an update.
So I annotated the columns this way
@Column(name = "DATE_CREATED", updatable = false, insertable = false)
and wrote a before insert/update trigger to update these datetime values.
The only problem I might encounter in future is when I have to really update a datetime field from the UI
Anyone here using an Oracle 9i db using timestamp columns in a Hibernate application and can give me some tips? - Basically I would like to update Oracle timestamp columns using Hibernate.
Thanks
Franco