我正在调用一个返回选择结果的过程。 我在 MySQL 中进行了测试,程序运行良好。
Call timeline_procedure(1)
但是当我从 hibernate 调用时,我收到错误
java.lang.IllegalArgumentException: 要遍历的节点不能为空!
调用该过程的代码是
EntityManagerFactory emf = Persistence.createEntityManagerFactory(
"Teste", properties);
EntityManager em = emf.createEntityManager();
em.getTransaction().begin();
List<Timeline> result = em
.createQuery("Call timeline_procedure(:accountId)", Timeline.class)
.setParameter("accountId", accountId)
.getResultList();
em.getTransaction().commit();
em.close();
最佳答案
不能用HQL,用SQL试试
List<Timeline> result = em
.createSQLQuery("Call timeline_procedure(:accountId)")
.addEntity(Timeline.class))
.setParameter("accountId", accountId)
.list();
关于java - 带返回列表 hibernate 的调用过程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35139447/