【发布时间】:2015-07-19 08:07:59
【问题描述】:
我有 3 张桌子:
用户 ->>- 多对多 ->- 用户应用程序 ->>- 多对多 ->>- 应用程序
用户拥有:
用户ID
用户名
用户应用:
用户ID
applicationId
应用:
applicationId
应用程序名称
我没有成功创建返回一个特定用户的每个应用程序的 HQL 查询。
我的 HQL:
select a.userId, a.userName from Application b join b.userId a where b.userId = 1
简化我想做的查询:from Application WHERE Userapp.userID = 1
你能帮我吗:)?
编辑:
我的工具:
Netbean 8.x
休眠插件
第二个错误:org.hibernate.hql.internal.ast.QuerySyntaxException: Userapp is not mapped
当我从数据库创建休眠映射文件和 POJO 时,它会为我创建 2 个对象:用户和应用程序。但不是关联表“Userapp”
我的 hibernate.reveng.xml :
<hibernate-reverse-engineering>
<schema-selection match-catalog="allin"/>
<table-filter match-name="user"/>
<table-filter match-name="application"/>
<table-filter match-name="userapp"/>
</hibernate-reverse-engineering>
问候
【问题讨论】:
-
我觉得应该是
User 1--* UserApp *--1 Application;) -
我在之后更正它;)谢谢
标签: mysql sql hibernate many-to-many hql