-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: Accessing database defaults after save?
PostPosted: Wed Nov 16, 2005 4:21 am 
Newbie

Joined: Wed Nov 16, 2005 4:04 am
Posts: 3
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 2

I hope the answer to this isn't too obvious, I have searched, (note, yes i'm a hibernate newbie) :)

I've have a database field which is filled out by my database (via a default value), how can I get the value of this back after I save my hibernate object?

I currently have the field mapped as


Code:
<property name="dateCreated" type="date" not-null="false" update="false" insert="false">
          <column name="date_created" />
    </property>


Straight after saving my object to the database I would like to be able to access this field, however it is of course "null".


Anyone know how I can implement this? or am I restricted to refetching my object manually if I want to access this field?

Cheers.
Matt.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 16, 2005 5:05 am 
Newbie

Joined: Mon Oct 03, 2005 8:27 am
Posts: 13
Have you tried to force a
Code:
session.flush()


?

I think yes, but you haven't posted any code....

-

Please don't forget to credit ,-)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 16, 2005 5:19 am 
Newbie

Joined: Wed Nov 16, 2005 4:04 am
Posts: 3
yeh i have tried that, thanks for the suggestion though


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 16, 2005 9:12 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
session.refresh(x)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 16, 2005 7:06 pm 
Newbie

Joined: Wed Nov 16, 2005 4:04 am
Posts: 3
thanks max, its not ideal, but should be fine, cheers.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.