-->
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: find() using an object in the where clause
PostPosted: Sun Jul 18, 2004 7:43 am 
Newbie

Joined: Sat Jul 17, 2004 6:39 am
Posts: 7
Hello,

I have an object with a composite id. I'd like to determine whether it exists using the find() method, but I don't want to have to list the criteria (i.e. obj.pk1=? and obj.pk2=? ...)

Can't I do something like find("from Object obj where obj=?",obj,Hibernate.OBJECT)?

Thanks,
Graeme


Top
 Profile  
 
 Post subject: API docs
PostPosted: Sun Jul 18, 2004 8:01 am 
Newbie

Joined: Sat Jul 17, 2004 6:39 am
Posts: 7
The API docs for load() say:

--
You should not use this method to determine if an instance exists (use find() instead).
--

It sure is easier to set your PK fields, use load() and catch the exception than it is to use a where clause like "obj.pk1=? and obj.pk2=? and obj.pk3=?..."

Isn't there a better way?

Graeme


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 18, 2004 10:37 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Use get()


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.