1 Reply Latest reply on Jan 16, 2007 3:38 AM by eekboom

    Generic List with @DataModel

      When using generic Lists, I get compiler warnings. If I want to have a generic return type, which of the following two options should be done? (Note the use of a cast in the second option.)

      Also, what's the disadvantage to not using @SuppressWarnings? It seems like it's optional...

      @DataModel
       @SuppressWarnings("unchecked")
       public List<Something> getSomethings() {
       return myQuery.getResultList();
       }


      Without @SuppressWarnings, the above gives the warning:
      Type safety: The expression of type List needs unchecked conversion to conform to List<Something>


      @DataModel
       @SuppressWarnings("unchecked")
       public List<Something> getSomethings() {
       return (List<Something>) myQuery.getResultList();
       }


      Without @SuppressWarnings, the above gives the warning:
      Type safety: The cast from List to List<Something> is actually checking against the erased type List


      Why is this error showing up in the second case. If I'm casting, shouldn't I be able to leave off @SuppressWarnings with no problem?