Enlightensoft's Blog

Helping in your each step

  • Categories

  • Authors

How to use Entity Name, specified in hbm.xml in DetachedCriteria???

Posted by Pankil Patel on September 26, 2011

 How to use Entity Name, specified in hbm.xml in DetachedCriteria???

OR

How to use OR Restriction in Criteria Query???

DetachedCriteria criteria = DetachedCriteria.forEntityName(“staff_phase2”);

Criterion crit1 = Restrictions.ilike(“lastName”, searchText.trim(), MatchMode.START);

 Criterion crit2 = Restrictions.ilike(“firstName”,searchText.trim(), MatchMode.START);

Criterion staffSearchCriterion = Restrictions.or(crit1, crit2); 

criteria.add(staffSearchCriterion);

Please find hbm.xml file used for this post, for your refrence: entity-name

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: