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) ]