Hibernate version: 3.2.5 GA
Hi there,
I'm trying to create a Criteria query that corresponds to the following HQL:
Code:
select new map(catalog as cat, artist as art) from Catalog catalog left join catalog.albums album left join album.artists artist where album.name = 'Aftermath'
So far the closest I've come is the following:
Code:
final Criteria criteria = session.createCriteria(Catalog.class);
criteria.createAlias("albums","alb");
criteria.add(Restrictions.eq("alb.name","Aftermath"));
criteria.createAlias("alb.artists", "art");
criteria.setResultTransformer(Criteria.ALIAS_TO_ENTITY_MAP);
final List<Map<String,Object>> map = criteria.list();
That works just fine, but of course I get three entities in each map entry, instead of the two entries of the original. I would like to exclude the unwanted album entity so that the generated SQL is equivalent to that produced for the HQL query, but cannot for the life of my figure out how to do so.
Any suggestions?