如何使用Hibernate< subselect> ;: [英] How to use Hibernate <subselect>:
问题描述
$ b
(1)hibernate映射中的子选择是什么?
(2) )如何在hbm文件中映射subselect?
(3)如果我使用subselect检索值,那么如何在java Action类中获取检索值。 b $ b
- 根据 section 5.1.3 ,
subselect
元素用于定义一个基于任意本地查询结果的只读/不可变实体。
-
在同一个源代码中,只需使用
subselect
code> class 元素而不是 -
使用
中的查询中的列创建映射后,子查询
元素,您应该可以像访问任何其他实体一样访问属性。
table
属性中,然后使用查询中定义的列名作为属性映射中的列名称。 (第5.1.3节逐字逐句如下) < class name =总结>
< subselect>
从项目
中选择item.name,max(bid.amount),count(*)
加入bid.item_id = item.id $ b $ group by item.name
< / subselect>
< synchronize table =item/>
< synchronize table =bid/>
< id name =name/>
...
< / class>
i am new to hibernate. i need to understand the following questions :
(1) What is subselect in hibernate mapping?
(2) How to map subselect in hbm file?
(3) If i retrieve values using subselect then how to get the retrieved values in java Action class.
- Based on the description given in section 5.1.3, the
subselect
element is used to define a read-only/immutable entity which is based on the results of an arbitrary native query. From the same source, one simply uses
subselect
within aclass
element instead of thetable
attribute and then uses the column names defined in the query as column names in the property mapping. (the following is taken verbatim from section 5.1.3)<class name="Summary"> <subselect> select item.name, max(bid.amount), count(*) from item join bid on bid.item_id = item.id group by item.name </subselect> <synchronize table="item"/> <synchronize table="bid"/> <id name="name"/> ... </class>
After you create a mapping using columns from the query in the
subselect
element, you should be able to access the properties just as you would for any other entity.
这篇关于如何使用Hibernate< subselect> ;:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!