-->
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: Error When Selecting into a DTO and Using LEFT JOIN FETCH
PostPosted: Thu Feb 28, 2008 12:43 pm 
Regular
Regular

Joined: Wed Nov 17, 2004 11:49 am
Posts: 65
Location: Pittsburgh
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:
JBoss 4.2.1GA

OK, I have the following query:

Code:
            " SELECT DISTINCT " +
//            "    new " + ReportSummary.CLASS_NAME + " ( " +
            "         report " +
//            "     ) " + //end ReportSummary constructor
            " FROM " +
            "     Report report " +
            "     LEFT JOIN FETCH report.workflowCycleState "


Which works fine (it returns Collection<Report> with the state association pre fetched, however, I actually want to map this to a DTO, ReportSummary and when I add this logic (the two commented out lines above), I get:

Full stack trace of any exception that occurs:

org.hibernate.QueryException: query specified join fetching, but the owner of the fetched association was not present in the select list [FromElement{explicit,not a collection join,fetch join,fetch non-lazy properties,classAlias=null,role=null,tableName=RECONACCOUNTWORKFLOWHISTORY,tableAlias=workflowcy1_,origin=RECONTACCOUNTHISTORY report0_,colums={report0_.RECONID ,className=com.chessys.tee.recon.cycle.persistence.WorkflowCycleState}}] [ SELECT DISTINCT new com.chessys.tee.recon.search.ReconSummary ( report ) FROM com.chessys.tee.recon.report.persistence.Report report LEFT JOIN FETCH report.workflowCycleState WHERE report not in (select distinct link.report from com.chessys.tee.recon.report.persistence.ReportToGroupLink link) ]; nested exception is: java.lang.IllegalArgumentException: org.hibernate.QueryException: query specified join fetching, but the owner of the fetched association was not present in the select list [FromElement{explicit,not a collection join,fetch join,fetch non-lazy properties,classAlias=null,role=null,tableName=RECONACCOUNTWORKFLOWHISTORY,tableAlias=workflowcy1_,origin=RECONTACCOUNTHISTORY report0_,colums={report0_.RECONID ,className=com.chessys.tee.recon.cycle.persistence.WorkflowCycleState}}] [ SELECT DISTINCT new com.chessys.tee.recon.search.ReconSummary ( report ) FROM com.chessys.tee.recon.report.persistence.Report report LEFT JOIN FETCH report.workflowCycleState WHERE report not in (select distinct link.report from com.chessys.tee.recon.report.persistence.ReportToGroupLink link) ]


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.