休眠标准:没有映射关联的连接表 [英] Hibernate criteria: Joining table without a mapped association

查看:91
本文介绍了休眠标准:没有映射关联的连接表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用Hibernate的标准api来制定一个连接两个实体的特定查询。比方说,我有两个实体,一个拥有宠物的拥有者的宠物和所有者,但最关键的是该关联未映射到Java注释或xml中。



使用hql,I可以通过在查询中指定连接来选择拥有名为'fido'的宠物的所有者(而不是将一组宠物添加到所有者类)。

可以相同使用休眠标准来完成?如果是这样的话,怎么样?



感谢,
J

解决方案

我的理解是,如果你使用HQL来做到这一点,那么你使用过滤器创建笛卡尔联接,而不是使用内部联接。标准查询不支持这样做。


I'd like to use Hibernate's criteria api to formulate a particular query that joins two entities. Let's say I have two entities, Pet and Owner with a owner having many pets, but crucially that association is not mapped in the Java annotations or xml.

With hql, I could select owners that have a pet called 'fido' by specifying the join in the query (rather than adding a set of pets to the owner class).

Can the same be done using hibernate criteria? If so how?

Thanks, J

解决方案

My understanding is that if you do this using HQL, you are creating a Cartesian join with a filter, rather than an inner join. Criteria queries do not support doing this.

这篇关于休眠标准:没有映射关联的连接表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆