aspose file tools*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Generics with query.getResulList Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Generics with query.getResulList" Watch "Generics with query.getResulList" New topic
Author

Generics with query.getResulList

Remko Strating
Ranch Hand

Joined: Dec 28, 2006
Posts: 893
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.



Remko (My website)
SCJP 1.5, SCWCD 1.4, SCDJWS 1.4, SCBCD 1.5, ITIL(Manager), Prince2(Practitioner), Reading/ gaining experience for SCEA,
Niranjan Deshpande
Ranch Hand

Joined: Oct 16, 2005
Posts: 1277
Hi Remko, Please check your PM!


SCJP 1.4 - 95% [ My Story ] - SCWCD 1.4 - 91% [ My Story ]
Performance is a compulsion, not a option, if my existence is to be justified.
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

Please check your PM!

Can't this be shared with everybody ?


[My Blog]
All roads lead to JavaRanch
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

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

Joined: Dec 28, 2006
Posts: 893
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
 
subject: Generics with query.getResulList