I have the following code in a DAO
String selectStatement =
"select {campaignFinishedProduct.*}, {finishedProduct.*} " +
"from gpmq.pack_compliance campaignFinishedProduct " +
" join gpmq.products finishedProduct on " +
" campaignFinishedProduct.manf_id_n = finishedProduct.manf_id_n and " +
" campaignFinishedProduct.upc_c = finishedProduct.upc_c and " +
" campaignFinishedProduct.upc_sufx_c = finishedProduct.upc_sufx_c " +
" left outer join gpmq.sap_resc_upc_xref_v b on " +
" campaignFinishedProduct.gcm_id = b.gcm_id and " +
" campaignFinishedProduct.manf_id_n = b.manf_id_n and " +
" campaignFinishedProduct.upc_c = b.upc_c and " +
" campaignFinishedProduct.upc_sufx_c = b.upc_sufx_c " +
"where ( b.gcm_id is null or b.manf_id_n is null or b.upc_c is null or b.upc_sufx_c is null ) ";
try {
mAnswer = HibernateConnector.getDefault().getSession().createSQLQuery( selectStatement )
.addEntity( "campaignFinishedProduct", CampaignFinishedProduct.class )
.addJoin( "finishedProduct", "campaignFinishedProduct.finishedProduct" )
.list();
} catch( HibernateException ex ) {
throw new DatabaseException( "Unable to load unmapped Packing Campaign Components", ex );
}
Trying to get instances of CampaignFinishedProducts, which hold onto FinishedProducts via a key-many-to-one relationship. See HBM file below.
<class name="CampaignFinishedProduct" table="PACK_COMPLIANCE">
<composite-id>
<key-property name="campaignIdentifier" column="GCM_ID" type="integer" />
<key-many-to-one
name="finishedProduct"
class="com.nppc.mes.domain.productdefinition.FinishedProduct">
<column name="MANF_ID_N"/>
<column name="UPC_C"/>
<column name="UPC_SUFX_C"/>
</key-many-to-one>
</composite-id>
<property name="status" column="CM_STATUS" type="campaignStatus" />
</class>
I get the following error: unable to resolve property [name=finishedProduct] to corresponding index.
I have used this construct in other places to do join queries with Raw SQL. Only difference I can see is that the object I am trying to do the join fetch with is part of the composite-id.
Is this not supported in this situation?
|