gpt4 book ai didi

java - 如何在 hibernate 映射文件中创建子句?

转载 作者:行者123 更新时间:2023-11-30 11:58:15 24 4
gpt4 key购买 nike

我想在获取时在hibernate映射文件中添加一个(where)条件,我该怎么做,例如 fetch="select"where id != 1 ,我也不使用注释,所以请在映射 (hbm) 文件中指定。

最佳答案

根据 Hibernate 文档,您可以指定 where映射集合时的子句:

6.2. Collection mappings

(...) The <map> element is representative:

<map
name="propertyName" (1)
table="table_name" (2)
schema="schema_name" (3)
lazy="true|extra|false" (4)
inverse="true|false" (5)
cascade="all|none|save-update|delete|all-delete-orphan|delet(6)e-orphan"
sort="unsorted|natural|comparatorClass" (7)
order-by="column_name asc|desc" (8)
where="arbitrary sql where condition" (9)
fetch="join|select|subselect" (10)
batch-size="N" (11)
access="field|property|ClassName" (12)
optimistic-lock="true|false" (13)
mutable="true|false" (14)
node="element-name|."
embed-xml="true|false"
>

<key .... />
<map-key .... />
<element .... />
</map>

(...)

(9) where (optional): specifies an arbitrary SQL WHERE condition that is used when retrieving or removing the collection. This is useful if the collection needs to contain only a subset of the available data.

<class> 也支持此功能水平。

关于java - 如何在 hibernate 映射文件中创建子句?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3281831/

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