gpt4 book ai didi

java - hibernate HQL元素错误

转载 作者:行者123 更新时间:2023-12-01 05:59:13 25 4
gpt4 key购买 nike

我的 HibernateUserImpl 映射如下所示

<set name="groups" table="OS_USER_GROUP" inverse="false" cascade="none" lazy="false">
<key column="user_id"/>
<many-to-many column="group_id" class="com.opensymphony.user.provider.hibernate3.ahxu.impl.HibernateGroupImpl"/>
</set>

我像这样进行 HQL 查询

select distinct hibuser from HibernateUserImpl hibuser, hibuser.groups.elements  hibgroup where hibuser.name = ? and hibgroup.name = ?

我收到 hibuser.groups.elements 错误。有什么我错过的吗?

控制台出错

org.hibernate.hql.ast.QuerySyntaxException: hibuser.groups.elements is not mappe
d [select distinct hibuser from com.opensymphony.user.provider.hibernate3.ahxu.i
mpl.HibernateUserImpl hibuser, hibuser.groups.elements hibgroup where hibuser.n
ame = ? and hibgroup.name = ?]

最佳答案

我认为您需要进行明确的加入

    select distinct hibuser 
from HibernateUserImpl hibuser
join hibuser.groups hibgroup
where hibuser.name = ? and hibgroup.name = ?

关于java - hibernate HQL元素错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1623457/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com