Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to insert a current date into the database table ?

 
shyam ji gautam
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
dear all

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>
</column>
</property>

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?
 
ntumba lobo
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
pravin kalbhor
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
better you can make that column to take default value at database level...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic