-->
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.  [ 8 posts ] 
Author Message
 Post subject: How to check is object unsaved in my code?
PostPosted: Fri Jan 07, 2005 2:53 am 
Newbie

Joined: Thu Jan 06, 2005 8:05 am
Posts: 13
Hi folks.

I need to check in my code is object unsaved (transparently according to unsaved-valu in hbm.xml), and only method I see is Interceptor.isUnsaved but it's no good since there's no Interceptor registered (null). What should I do now?

Regards,
Vjeran


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 07, 2005 8:20 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
register an interceptor - done when opening session.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 07, 2005 9:35 am 
Newbie

Joined: Thu Jan 06, 2005 8:05 am
Posts: 13
hmmm... that wouldnt solve the problem because as I understand, Interceptor.isUnsaved() is called when some object is passed to saveOrUpdate() method, but I want to check isUnsaved() in my business methods, before I call any session method.

I guess I'll just have to use in my business method something like:

if (object.getId() == null) {
...
}
although it's not transparent solution, since it is specific to case when unsaved-value is null (default).

-Vjeran


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 07, 2005 9:39 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
and session.isSaved(object o) isn't good enough ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 07, 2005 9:40 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
(sorry - that is only visible on SessionImplementor - not on Session)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 07, 2005 9:41 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
(sorry - that is only visible on SessionImplementor - not on Session)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: How do I check if an object is unsaved in code?
PostPosted: Mon Jun 06, 2005 9:05 pm 
Newbie

Joined: Mon Jun 06, 2005 3:49 pm
Posts: 3
Is there a public API exposed to check this? I can just do the getId() check, but I would like my code to still work if the id scheme changes.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 07, 2005 1:38 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
no nothing public. look in jira and see if its suggested if not then suggest it.

_________________
Max
Don't forget to rate


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