Hi guys,
right now I'm translating some HQL-code into programmed Java code using the Criteria from Hibernate.
I want to select some objects of the type Sector grouped by the sector.id and ordered by the size of its containing Publiction-Set. My HQL code is working fine:
My criteria-code looks like:Code:SELECT sector FROM Sector AS sector LEFT JOIN sector.publications AS publication WHERE sector.name LIKE :firstCharacter GROUP BY sector.id
The order is correct, but I get list of Object[] containing the id and the publications count. Indeed this ist right, but I want to get a list only filled with Sector-Objects.Code:Criteria criteria = session.createCriteria(Sector.class) .createAlias("publications", "publication",Criteria.LEFT_JOIN) .setProjection(Projections.projectionList() .add(Projections.groupProperty("id")) .add(Projections.alias(Projections.count("publication.id"),"publicationCount"))) .addOrder(sort("publicationCount", ascending)) .addOrder(sort("name", ascending)).list();
Can someone can help me?
THX
Sebastian


Reply With Quote
