4 Replies Latest reply on Sep 7, 2010 6:49 AM by nimo stephan

    Unchecked cast from List - typesafe injection

    nimo stephan Master

      I get a debug-warning:


      "Type safety: Unchecked cast from List to List<Users>"




      for that:


      public List <User> getUsers() 
      { 
                return (List <Users>) entityManager.createNamedQuery("getUsers").getResultList();
      }




      Can I avoid a unchecked-cast warnings with weld.


      Is there a way to use a qualifier or the like?


      I dont want to use


      @SuppressWarnings(unchecked) to all my queries.


      In Warp-persist from Google Guice, I can say something like:


      @Finder(namedQuery = "getUsers")
      public List<Foo> getUsers(@Named("id") final int id) {
          throw new AssertionError();
      }



      So you see, no unchecked-cast warning occurs in warp-persist.


      How can I do that with weld?


      Is there something like that in seam 3?


      It is really annoying to have all that surpress-warnings or unchecked-cast-exceptions all over my queries.