【问题标题】:JPA Hibernate createNativeQuery throwing up with setParameterJPA Hibernate createNativeQuery 抛出 setParameter
【发布时间】:2012-07-13 02:07:54
【问题描述】:

这是查询(我已对其进行了格式化以便人类更容易阅读:)

Query q = em.createNativeQuery("select group_name 
                                from groups g 
                                join credentials_groups_lu cgl on 
                                g.group_id = cgl.group_id 
                                and g.parent_id = cgl.parent_id 
                                where cgl.credential_id  = :credentialId");
q.setParameter("credentialID", credentialId);

当它到达设置的参数行时,它会呕吐。我在某个地方读到了 hibernate 不喜欢 nameNativeQueries。这是同一个问题的一部分吗?如果是这样,如何绕过它。

提前感谢那些回答。 :) 我不想听起来脾气暴躁,但我不想学习如何使用“纯”ORM 来做到这一点。我可以做到这一点。我需要弄清楚如何做到这一点。

【问题讨论】:

    标签: hibernate jpa


    【解决方案1】:

    我认为可能是你的SQL中的参数名称和setParameter中使用的key造成的,一个是credentialId,另一个是credentialID(Id vs ID)

    【讨论】:

    • 有时需要第二双眼睛。谢谢。你是一位绅士和学者(我需要拼写检查才能拼写学者)。
    猜你喜欢
    • 1970-01-01
    • 2012-10-18
    • 1970-01-01
    • 2019-03-28
    • 2012-04-17
    • 2023-04-09
    • 2017-06-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多