Hibernate version: 3.2.2
I have a situation where I have a table like this
create table User(
id NUMBER(2) PRIMARY KEY,
name VARCHAR2(10),
date_logged DATE);
I can update, insert using Native SQL with Hibernate but how would one
update the User table with SYSDATE value.
User user = (User)session.load(User.class, new Long(10));
//is there a way to set the date logged to sysdate
//I do not want to use Timestamp from Java because the App Server and DB are in separate machine and DB server's time is the trusted time.
user.setDateLogged(..);
I guess what I wanted to know is whether I can use SYSDATE when I am using session.saveOrUpdate()
What I do not prefer to do to solve this:
1. disable this column in mapping file for update, insert and create a update trigger in oracle side
2. use Native SQL/HQL
3. sql timestamp because DB time != App server time
Please reply with any suggestions.
I found this tag
<timestamp name="dateLogged" column="date_logged" source="db"/>
But do we still need to set java.sql.Timestamp
in java code.
user.setDateLogged(new Timestamp(System.currentTimeMillis());
If so,
new Timestamp(System.currentTimeMillis() is redundant
it would be better to have support for DB side keywords/functions
|