我有以下复杂查询,它是视图,我们希望消除视图并直接映射到表,我们使用Hibernate2。是否可以将多个表映射到Hibernate2中的一个类?这是我的询问。
SELECT DISTINCT
r.id,
rtype.name AS model_object_type_name,
rtype.id AS model_object_type_id,
c.id AS case_id,
r.source_item_id AS person_id,
c.file_number,
c.start_date,
a.app_start_date AS app_date,
a.app_start_time,
a.outcome_type AS app_outcome,
c.primary_reference_id,
aval.string_value AS last_mncis_refresh
FROM my.case_file AS c INNER JOIN
my.relation AS r ON c.id = r.target_item_id INNER JOIN
my.item_type AS rtype ON r.item_type_id = rtype.id INNER JOIN
my.person AS p ON p.id = r.source_item_id INNER JOIN
my.relation AS rc ON c.id = rc.target_item_id INNER JOIN
my.attr_value AS aval ON c.id = aval.item_id AND aval.name='test'
INNER JOIN my.item_type AS ptype ON p.item_type_id = ptype.id
WHERE (ptype.name = 'Test')
AND (rtype.name = 'Test1' OR rtype.name = 'Test2' OR rtype.name = 'Test3')
AND (rc.name = 'Test4')
感谢。
答案 0 :(得分:1)
这是可能的。请参阅description of the join element(该文档适用于hibernate 3.5版。我不知道该元素首先引入了哪个版本。请查看您的版本)。直到hibernate规范,连接仅针对1:1关系设计,但如果它仅用于读取n:1关系也应该起作用(但对于更新,插入和删除,可能不适用于:1关系) )。