使用 return 列表休眠的调用过程
Call procedure with return list hibernate
我正在调用 return select 结果的过程。
我在 MySQL 中进行了测试,程序运行良好。
Call timeline_procedure(1)
但是当我从休眠中调用时,我收到错误
java.lang.IllegalArgumentException: node to traverse cannot be null!
调用程序的代码是
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();
我正在调用 return select 结果的过程。 我在 MySQL 中进行了测试,程序运行良好。
Call timeline_procedure(1)
但是当我从休眠中调用时,我收到错误
java.lang.IllegalArgumentException: node to traverse cannot be null!
调用程序的代码是
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();