-->
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.  [ 1 post ] 
Author Message
 Post subject: implement a find by example usefull also for id
PostPosted: Mon Jun 18, 2007 11:12 am 
Beginner
Beginner

Joined: Thu Jan 20, 2005 1:45 pm
Posts: 49
hi all
I noticed by hibernate reference that it's impossible getting pojo by example when in the example is specified just the id.
I implemented this (does not work of course by id):

public Collection findByExample(Object example) throws PersistenceException {
log.info("findByExample...");
Collection collection;
try {

Criteria crit = HibernateSessionFactory.getSession()
.createCriteria(mappedClass);
collection = crit.add(Example.create(example).enableLike(MatchMode.EXACT)).list();

} catch (HibernateException ex) {
throw new PersistenceException(ex);
}
return collection;
}

I need a function that does the find by example also when in the example is specified just the id!


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

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.