-->
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.  [ 3 posts ] 
Author Message
 Post subject: Persist an empty object
PostPosted: Thu May 28, 2009 7:10 pm 
Newbie

Joined: Thu May 28, 2009 7:05 pm
Posts: 2
I've just started investigating Hibernate and I have a newbie question.

I am trying to create an empty object, "mark it as persistent", then set the fields, hoping that when the session is flushed, proper insert statement will happen. However, I could not make it working with save or persist methods – it is failing on not null properties. Is this possible and if not, is there a workaround?

The reason why I am trying to do this is that I have a rich client user interface that is setting the properties after an empty object is created. Hibernate is doing a great job of tracking changed (updated) objects, and something similar for inserts would be great. Otherwise I will have to programmatically track new objects and once all properties are set, to call save or persist.


Top
 Profile  
 
 Post subject: Re: Persist an empty object
PostPosted: Fri May 29, 2009 4:48 am 
Newbie

Joined: Tue May 19, 2009 11:22 am
Posts: 6
I am little confused about this question.

From what I understanding, "dynamic-insert" and "dynamic-update" should solve your problem.

Please let me know what you think.


Top
 Profile  
 
 Post subject: Re: Persist an empty object
PostPosted: Fri May 29, 2009 1:14 pm 
Newbie

Joined: Thu May 28, 2009 7:05 pm
Posts: 2
I don't think that dynamic insert would solve it. To clarify, here is the scenario that I would like to do:

1. Instantiate an empty object.
2. Call Session.persist or something similar (this is what I refer to as "mark as persistent", I am not sure if such thing exists).
3. Call setters to populate the fields.
4. Commit or flush (this is where the actual insert will happen).


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.