-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: ClassCastException with Left Outer Join
PostPosted: Thu Jun 23, 2011 1:40 pm 
Newbie

Joined: Thu Apr 28, 2011 11:53 am
Posts: 4
I have a query like so (in queries.xml):

Code:
select rec from Request rec
   left outer join rec.approvals
where rec.submitter.badgeNumber = :employeeBadge
or rec.requester.badgeNumber = :employeeBadge
order by rec.dateSubmitted desc


And when I get the result list and try to iterate through it, I get:

java.lang.ClassCastException: org.aero.libreq.entity.RequestEntity cannot be cast to [Ljava.lang.Object;

Here's my java (error occurs on this line: Object[] objects = (Object[])iterator.next();):

Code:

   public List<Request> toModelList(Collection<RequestEntity> entityList) {
      List<Request> modelList = new ArrayList<Request>();
      Iterator iterator = entityList.iterator();
      while (iterator.hasNext()) {
         Object[] objects = (Object[])iterator.next();
         RequestEntity entityObject = (RequestEntity)objects[0];
         Request modelObject = toModel(entityObject);
         modelList.add(modelObject);
      }
      return modelList;
   }



While stepping through the method, the entityList is passed in as an ArrayList<E> with elementData=Object[3360] and each element is a RequestEntity.

What am I missing here?
Thanks!


Top
 Profile  
 
 Post subject: Re: ClassCastException with Left Outer Join
PostPosted: Thu Jun 23, 2011 2:41 pm 
Newbie

Joined: Thu Apr 28, 2011 11:53 am
Posts: 4
I read the Hibernate community documentation about using the 'with' keyword. The query and error are:

Code:

06/23/11 11:16:49 ERROR  [main] org.hibernate.impl.SessionFactoryImpl:405 - Error in named query: getRequestsForEmployee
org.hibernate.hql.ast.InvalidWithClauseException: with-clause expressions did not reference from-clause element to which the with-clause was associated [select rec from org.aero.libreq.entity.RequestEntity rec left outer join rec.approvals as approval with approval.approver.badgeNumber = :employeeBadge where rec.submitter.badgeNumber = :employeeBadge or rec.requester.badgeNumber = :employeeBadge order by rec.dateSubmitted desc]



I am using hibernate-core-3.3.2.GA. What have I got wrong?

Thanks!!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.