Note that there are some explanatory texts on larger screens.

plurals
  1. POHibernate Criteria.ALIAS_TO_ENTITY_MAP to ArrayList Student missing
    primarykey
    data
    text
    <p>I have one to many relationship I need to fetch eager the associate table as well filters the 2 tables using criteria. Here is my code..</p> <pre><code>public ArrayList&lt;Student&gt;getListOfStudents() { Session session = getHibernateTemplate().getSessionFactory().openSession(); Criteria like = session.createCriteria(Student.class) .setResultTransformer(Criteria.ALIAS_TO_ENTITY_MAP); prepareForSelect(like);//some filtering Criteria innerCriteria = like.createCriteria("phone","p",JoinType.LEFT_OUTER_JOIN); prepareForSelect(innerCriteria);//same filtering but in phone now.. like.addOrder(Order.asc("c01")); Iterator&lt;java.util.Map&lt;Object,Object&gt;&gt; ite = like.list().iterator(); HashSet&lt;Student&gt;students= new HashSet&lt;Student&gt;(); while(ite.hasNext()) { java.util.Map&lt;Object,Object&gt; map = ite.next(); Student aStudent = (Student)map.get(Criteria.ROOT_ALIAS); Phone phone = (Phone)map.get("p"); if(student.contains(aStudent)) students.addPhoneToStudent(phone); //add to phone hashSet in Student.class else { student.setListOfPhones(new HashSet&lt;Phone&gt;(0)); students.addPhoneToStudent(phone); students.add(student); } session.close(); return new ArrayList&lt;Student&gt;(students); } </code></pre> <p>everything is OK but if a Student dont have a phone which fullfill the criteria restrictions(isValidPhone=true) the Student is not in the resultset i need still the student even if not have a valid phone because the App should be able to add a new phone for the student can somebody give a tip. thank a lot</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload