Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Generics with query.getResulList

 
Remko Strating
Ranch Hand
Posts: 893
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By generating a list from a namedQuery within the statement query.getResultList I get always a type safety warning which I now suppress with an annotation @SuppresWarnings ("unchecked").

This feels not right and I will try to solve this by returning ResultList with a given Object. I couldn't find a way of doing this in the JavaDoc but maybe you know a good solution.


 
Niranjan Deshpande
Ranch Hand
Posts: 1277
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Remko, Please check your PM!
 
Christophe Verré
Sheriff
Pie
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please check your PM!

Can't this be shared with everybody ?
 
Christophe Verré
Sheriff
Pie
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JPA 2.0 will have new methods which use a new Result interface to return query results :
List<Result> getTypedResultList();
Result getTypedSingleResult();

I think this will allow to suppress this type of warning.
 
Remko Strating
Ranch Hand
Posts: 893
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Christophe,

Thanks for your feedback so with the current JPA this is not possible. So I will suppress the warning until JPA 2.0 is final.

 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic