Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate Join Problem

 
C Rakesh
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have the following HQL(Join operation) which should return two objects of type RecruitmentManagerSchedule and RecruitmentManagerRequirement. The HQL should return two objects

try {
Query query = session.createQuery("select recMgrSch, recMrgReq from " +
"com.hrms.persistence.beans.RecruitmentManagerSchedule as recMgrSch, " +
"com.hrms.persistence.beans.RecruitmentManagerRequirement as recMrgReq " +
"where recMgrSch.requirementid = recMrgReq.requirementid and recMgrSch.statusid = :statusId");
query.setInteger("statusId", 31);
log.debug("Getting Query : " + query);
List remindersList = executeQuery(query, session);
log.debug("remindersList size : " + remindersList.size());
return remindersList;
}

the code above execute fine and prints "remindersList size : 3" in logs

I am iterating the remindersList and assigning the list values into an Object array.

while(reqIterator.hasNext()){
//since the list has two object types(RecruitmentManagerSchedule and RecruitmentManagerRequirement),
//assign the list to object array, and take the objects from the array
Object[] resultObj = {(Object[])reqIterator.next()};
RecruitmentManagerSchedule recMgrSch = (RecruitmentManagerSchedule)resultObj[0];
RecruitmentManagerRequirement recMgrReq = (RecruitmentManagerRequirement)resultObj[1];
}

Now I am expecting that I'll get RecruitmentManagerSchedule object from resultObj[0] and RecruitmentManagerRequirement object from resultObj[1]. But I am getting the exception
"Exception While listing the Reminders java.lang.ClassCastException: [Ljava.lang.Object;"

Also I am getting only one object in the array "resultObj" instead of two.
If I am slelecting only one object in the HQL (ie, select recMgrSch from .....) the above code works fine.

Please guide me

Thanks,
Rakesh
 
Sean Clark
Rancher
Posts: 377
Android Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey,

remember and use the code tags - makes it easier to read.

Also take out the curly braces from this line:


Sean
 
C Rakesh
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sean Clark wrote:

remember and use the code tags - makes it easier to read.

Also take out the curly braces from this line:

Sean


Hi Sean,

Thanks!!! that was the issue . Once again thanks a lot.
How to use code tags??

Warm Regards,
Rakesh
 
Sean Clark
Rancher
Posts: 377
Android Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey,

Glad that helped.

When writing the message there is a "Code" button at the top. Press and the code tags will appear and then you can just put in your code between the tags.

Sean
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic