A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
Murach's Java Servlets and JSP
this week in the
Object Relational Mapping
how to insert a current date into the database table ?
shyam ji gautam
Joined: Sep 17, 2011
Sep 20, 2011 11:45:47
i am new to hybernate . i have one table called user_maintenance . in which there is one colunm called lastlogin date . i set the default value for this colunm using hbm file like
<property name="lastLogin" formula="(select sysdate from dual)" type="date" insert="false" >
<column name="LAST_LOGIN" length="7">
<comment>Last successful login date</comment>
but when i check using following query
select LAST_LOGIN from usermaintenance where user_id = 'shyam' ;
on the database command prompt it shows nothings means empty colunm why?
i want that this sysdate is also automatically insert into the database table (user_maintenance) for colunm LAST_LOGIN for particular user_id(shyam) when particular user_id will login into the system.
any suggestion please?
Joined: Oct 21, 2008
Sep 21, 2011 04:06:59
The easy way to create a new Date object in the Java code and set it in your persistent field. There is no need for a Hibernate formula for that.
SCJP 5 , SCWCD 5, SCEA 5
Joined: Oct 11, 2010
Sep 21, 2011 04:27:19
better you can make that column to take default value at database level...
With a little knowledge, a
cast iron skillet
is non-stick and lasts a lifetime.
subject: how to insert a current date into the database table ?
what i will use in hbm when we use sequence at backend side ?
what is the length of the Date?
save entity with SYSDATE
Association references unmapped class exception with hibernate
how to insert a current date into the databse colunm using hybernate ?
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014