[Solved] java.lang.ClassCastException: java.lang.String cannot be cast to


Your query looks like this: "SELECT E.username FROM MyUser E"

The E.username part will return a list of username Strings. It should be From MyUser to get MyUser objects.

Something like:

List<MyUser> p1 =sn.createQuery("FROM MyUser").list();

1

solved java.lang.ClassCastException: java.lang.String cannot be cast to