Win a copy of Java 9 Revealed this week in the Features new in Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Join Query  RSS feed

 
James Daniel
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using Hibernate with Spring. I need to write a join query. The query seems to run OK since I see the expected size of the generated list. Problem is I get a cannot be cast to <Object type I am trying to populate>. I am using getHibernateTemplate().find(query) and the select fields are only of that type. Why won't it create the objects of type I want?
 
Gamini Sirisena
Ranch Hand
Posts: 378
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
some join queries return a list containing an Object[] which in turn
contain the persistent objects that are expected from the query.

You could do something like and see if
select s from Supplier s inner join...

rather than from Supplier s inner join..

if you get duplicate resutls select distinct s from.. would do the
trick.

Hope this helps..
 
James Daniel
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Gamini,

Thanks for the suggestion. I'm sorry I hadn't replied until now. I will give that a try..

Jim
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!