I’m doing a right outer join of Cats with Owners, how can i get as a result a list of Owners?
Criteria criteria = session.createCriteria(Cats.class);
List<Owners> list= criteria.createCriteria("owner",JoinType.RIGHT_OUTER_JOIN);
A cat has one owner but an owner can have many cats.
Edit:
The reason of this, is to be able to add restrictions to the criteria based on more relations, let me elaborate this.
Criteria criteria = session.createCriteria(Cats.class);
criteria.add(Restrictions.or(Restrictions.isNull("breed.pkBreed")).add(Restrictions.ne(breed.desc,"Egyptian cat")));
List<Owners> list= criteria.createCriteria("owner",JoinType.RIGHT_OUTER_JOIN);
In this case, i am retrieving all the non Egyptian cats owners and all the cats owners with currently no breed assigned, and this is my exact scenario, but with different data.
I know it sounds weird, but this is the exact query for my requirement.
Also, even if i don’t transform the list data, i have no clue of what’s in it, so i can iterate in it…
After a lot of headaches with the alias, i got what i wanted =)