Hibernate Session.list() returns a simple, raw List .
This is a completely legal Java syntax to pass to a parameterized collection ( List<Object[]> here). But because universal type information is destroyed at runtime, the compiler will issue a warning to let you know that it cannot guarantee that this cast will actually be valid. So this is just his way of telling you: "Hey, you play with fire here, I hope you know what you are doing, because I do not."
In this particular case, you cannot do anything to eliminate this warning, but you can take responsibility for ignoring it using the @SuppressWarnings annotation.
Olivier croisier
source share