我第一次使用 JPA,当我尝试查询 postgres 数据库时出现此错误:
Exception in thread "main" java.lang.ClassCastException: org.postgresql.util.PGobject cannot be cast to [Ljava.lang.Object;
代码是:
List<Results> r = em.createNativeQuery("SELECT r FROM RESULTS r\n"
+ "INNER JOIN SESSION S ON s.SESSION_ID = r.SESSION_ID WHERE s.SESSION_ID = '" + sessionId + "'").getResultList();
我已经尝试过使用 Object[],但错误仍然相同
List<Object[]> r = em.createNativeQuery("SELECT r FROM RESULTS r\n"
+ "INNER JOIN SESSION S ON s.SESSION_ID = r.SESSION_ID WHERE s.SESSION_ID = '" + sessionId + "'").getResultList();
有人知道怎么了?