Hi , I am new to Hibernate, but am facing the above problem.
here is my code details :
Code:
Pojo Class Table
TravelBatchParticulars -- Travel_Batch
BranchInfo -- BranchInfo
--There is no primary, foreign key's
My Query is :
String hq1 = " Select batch.BATCH_ID as BATCH_ID , batch.TRAVEL_BATCH as TRAVEL_BATCH, batch.BRANCH_ID as BRANCH_ID
from TravelBatchParticulars batch , BranchInfo info where batch.USER_NAME = info.userid and
batch.BRANCH_ID = info.branch_id " ;
List<TravelBatchParticulars> travelBatchList = new ArrayList<TravelBatchParticulars>();
travelBatchList = session.createQuery(hq1).list();
After executing , Println of travelBatchList.size() showing as 2.
but am not getting which objects present in this list ?
Code:
for(TravelBatchParticulars batchParticular : travelBatchList ) { // Here System posting the Exception
java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to com.arms.misreport.core.TravelBatchParticulars
Even i tried to change the query. but unable to handle the output object list :
Code:
String hq1 = " from TravelBatchParticulars batch , BranchInfo info " +
"where batch.USER_NAME = info.userid and batch.BRANCH_ID = info.branch_id " ;
Here generated hql showing the all columns from both the tables. i need data from first table only.
Thanks in Advance,