java - HQL WHERE clause where the condition is inside a hashset or list -


hi solving family tree problem.

i have pojo class family

public class family {   private int familyid;  private partners parents;  private hashset<person> children;  private hashset<family> descendantfamilies;  //getters , setters.  }   public class person {   private int personid;   private string name;   private gender gender; //enum class  //getters , setters. }  public class partners {  private person husband; private person wife; //getters , setters } 

now check if person has brothers or sisters, i have check through families person 1 among children of family. new hibernate. have never searched condition through list or hashset. please help.

hi try answer question because think you're looking elements keyword.
can check through families person 1 among children of family using below hql:-

select f  family f  (   :person in elements(f.children) ) 

this query give family containing person children. syntax like:-

 string hql = "select f family f  (:person in elements(f.children))";  query query = session.createquery(hql);  query.setentity("person",somepersonobject); 

also think might knowing still want tell when using hashset overriding equals , hashcode method important. define 2 person objects should considered equal.(possibly when there ids same)


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -