• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Get List of object in JPQL

 
Leo Adams
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!

It's make a moment I read this forum, and now I've a problem I think you can resolve.

I've created a JPQL request, that mades some matches between some persons

It's something like:

"Select o1,o2,o3 FROM ObjectTable as o1, ObjectTable as o2, ObjectTable as o3 WHERE o1.rightreference = o2.leftreference AND o2.rightreference = o3.leftreference AND o3.rightreference = o1.leftreference"

I was thinking it would return me List<List<ObjectTable>>, but it seems it's not the case because I've an typecasting error.

I hope you can help me

Leo
 
Ulas Ergin
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
since there is no code OR error message we need to guess your problem

consider seeing Query createNativeQuery(String sqlString, Class resultClass) of EntityManager
and keep in mind that List<Object> and List<MyClass> are not assignable.
 
Leo Adams
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm sorry, I've done a bad "work".

So:

The code was:



The generated query is: "SELECT d0, d1, d2 from Deal as d0, Deal as d1, Deal as d2 where d0.idOfferedService = d1.idRequestedService AND d0.status = 0 AND d1.idOfferedService = d2.idRequestedService AND d1.status = 0 AND d2.idOfferedService = d0.idRequestedService AND d2.status = 0"

The error was "...connot cast java.lang.object to java.lang.list" It was happening when I was trying to access to the second list:



The strange thing, is that if go with the debugger of netbeans, I see all informations, and all informations are corrects, final nodes "Deal" too.

I'm Ok to do that in SQL, but how can I receive the three requests objects?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic