-->
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: can I load Persitent object by unique keys not pk?
PostPosted: Thu Jun 15, 2006 5:37 am 
Newbie

Joined: Thu Jun 15, 2006 5:33 am
Posts: 1
I have to load by unique key.
can I have any method to do that?
I expect like the following,

session.loadByUniqueKey(Entityclass, property, value);


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 15, 2006 9:42 am 
Expert
Expert

Joined: Tue Apr 25, 2006 12:04 pm
Posts: 260
Code:
Criteria crit = session.createCriteria( MyPersistent.class );
crit.add( Restrictions.eq( "uniqPropertyName", propertyValueObject ) );
MyPersistent = (MyPersistent)crit.uniqueResult();


I guess the above code will be useful to you when you want object with the given business key.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 16, 2006 6:14 am 
Expert
Expert

Joined: Thu May 26, 2005 9:19 am
Posts: 262
Location: Oak Creek, WI
Hi,

I suppose you dont have a method to load a unique key like pk.

So you will have to use Criteria as the above poster said or an HQL.

I prefer Criteria.

_________________
RamnathN
Senior Software Engineer
http://www.linkedin.com/in/ramnathn
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.  [ 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.