i want to construct a a pojo with some records from 2 tables using Hibernate criteria api. I'm constructing a ProjectionList with needed records from the 1st table, because i don't have a bidirectional relationship between the 2 tabls , have only from 2nd to first i've made a DetachedCriteria(subcriteria) and made a projection for the needed record.
i don't know how to add the subcriteria to the ProjectionList for having an array of the needed records
Criteria criteria = currentSession.createCriteria(getClazz());
projectionList.add(Projections.property("name"), "name");
projectionList.add(Projections.property("str"), "street");
projectionList.add(Projections.property("nr"), "nr");
DetachedCriteria subcriteria=DetachedCriteria.forClass(B.class,"b");
subcriteria.createAlias("b.adress", "adr",CriteriaSpecification.LEFT_JOIN);
subcriteria.setProjection(Projections.property("adr.id"));
Thanks!!!