Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: James Rivera   on Mar 22 In Java Category.

  
Question Answered By: Latasha Wilson   on Mar 22

I have a example  of your problem wich work correctly



you can try it .



Criteria criteria  = session.createCriteria(Document.class)
.createAlias("pages", "pageAlias")

.add(Restrictions.eq(pageAlias.id", pages.getId())



you should first set a Alias name for a many side  of relation   if you imagine that there is a Document that has a Set of page  , then for page Object you set a pageAlias .

then add Restrictions like above . it finds your Object from a set or list  of objects by using

add(Restrictions.eq(pageAlias.id", pages.getId()) .



the code is like :



public class Document {



private Set Pages

........

}

Share: 

 

This Question has 6 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Hibernate Criteria question Or get search suggestion and latest updates.


Tagged: