-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Return DTO from criteria query with projections
PostPosted: Mon Aug 18, 2008 3:15 pm 
Newbie

Joined: Mon Aug 18, 2008 10:19 am
Posts: 5
Hi,

I need to return a DTO object from my criteria query instead of an array of objects. However, as I am using a projectionList it currently returns objects. Is there anyway to keep the functionality of the query but get it to return a list of DTO's

The code for the query is

Criteria crit = getSession().createCriteria(PostingDTO.class);
crit.setFetchMode("inspection", FetchMode.JOIN);
ProjectionList proj = Projections.projectionList();
Criteria inspectionCrit = crit.createAlias("inspection", "ins", CriteriaSpecification.LEFT_JOIN);
proj.add(Projections.max("ins.instructionDate"));
proj.add(Projections.groupProperty("id"));
inspectionCrit.setProjection(proj);
crit.list();


Any help with this would be greatly appreciated.

Thanks


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.