【问题标题】:Call procedure with return list hibernate带有返回列表休眠的调用过程
【发布时间】:2016-02-01 20:11:53
【问题描述】:

我正在调用一个返回选择结果的过程。 我在 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();

【问题讨论】:

    标签: java mysql sql hibernate hql


    【解决方案1】:

    你不能用HQL,用SQL试试吧

    List<Timeline> result = em
      .createSQLQuery("Call timeline_procedure(:accountId)")
      .addEntity(Timeline.class))
      .setParameter("accountId", accountId)
      .list();
    

    【讨论】:

      猜你喜欢
      • 2011-04-27
      • 1970-01-01
      • 2016-01-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-09-29
      • 2013-03-16
      • 2016-08-25
      相关资源
      最近更新 更多