If you really want to avoid the warnings, and you don't want to suppress them, the only way to do it is to copy the results of Query.list() manually into a new List<State>:
Quote:
List results = query.list();
List<State> newResults = new ArrayList<State>();
for (Object o : results) {
newResults.add((State) o);
}
return newResults;
That's the only "safe" way to do it as that's the only way that will guarantee that the resulting List<State> only contains State objects.
The reason you have to get the warnings is that at runtime a List and a List<State> object are both actually just plain List objects. So if query.list() returned a List ontaining anything other than State objects, the cast to List<State> would not cause any exception to be thrown - the program would continue fine, because no type checking of generics is done at runtime. Which might make debugging it difficult in future as you suddenly get a class cast exception popping up somewhere else in the program seemingly at random.
Of course you know that query.list() will only return State objects - but the compiler, and hence Eclipse, can't know that. Just suppress the warning - it has done its job, which is to ask you whether you are certain that the cast is valid.