Hi,
Will really appreciate any help on this. I am having an issue with ResultTransformer, I am using a store procedure to get data from MySQL DB.
If I create a signature in hbm.xml
CASE 1:
<sql-query name="testFact" callable="true"> <return alias="ArrayData" class="com.emc.ecc.datasource.spm.datamanager.dmfdata.DMFArrayInterval"/> {call spa_GetFactData(:unit,:categoryType,:aggType,:tableName,:id,:logicalIDs,:startKey,:endKey,:sortKey,:startRow,:numOfRow)} </sql-query>
and in code if I try
Query snapshotQuery = session.getNamedQuery("testFact"); snapshotQuery .setParameter("unit", aggTypeString) .setParameter("categoryType", category.prettyName()) .setParameter("aggType", aggTypeFunc) .setParameter("tableName", tableName) .setParameter("id", id) .setParameter("logicalIDs", idsString) .setParameter("startKey", DMFTimeDimension.getRightStartKey(startDate, aggregateType)) .setParameter("endKey", DMFTimeDimension.getRightEndKey(endDate, aggregateType)) .setParameter("sortKey", null) .setParameter("startRow", null) .setParameter("numOfRow", null);
That work's fine. But when I try to do
CASE 2:
Query snapshotQuery = session.createSQLQuery("call spa_GetFactData(:unit,:categoryType,:aggType,:tableName,:id,:logicalIDs,:startKey,:endKey,:sortKey,:startRow,:numOfRow)"); snapshotQuery .setParameter("unit", aggTypeString) .setParameter("categoryType", category.prettyName()) .setParameter("aggType", aggTypeFunc) .setParameter("tableName", tableName) .setParameter("id", id) .setParameter("logicalIDs", idsString) .setParameter("startKey", DMFTimeDimension.getRightStartKey(startDate, aggregateType)) .setParameter("endKey", DMFTimeDimension.getRightEndKey(endDate, aggregateType)) .setParameter("sortKey", null) .setParameter("startRow", null) .setParameter("numOfRow", null); .setResultTransformer(Transformers.aliasToBean(dbClass.factClassName));
ResultTransformer throws an error that property is not mapped (I make sure return class is same in both cases).
The difference I see SQLQueryImpl objects build differently in Case 1 "queryReturns" parameters are set but in case of ResultTransformer it's not.
The reason I don't want to use Case 1 because my Return class is different based on the input parameters and I have to repeat same store procedure with different return class. Where as in case 2 I can do that dynamically.
Is there any way I can set "queryReturns" parameter in case 2.
Thanks,
|