我正在调用一个返回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();
答案 0 :(得分:0)
您无法使用HQL,只需尝试使用SQL
List<Timeline> result = em
.createSQLQuery("Call timeline_procedure(:accountId)")
.addEntity(Timeline.class))
.setParameter("accountId", accountId)
.list();