我想知道是否有可能使用jpa或hibernate,构建一个查询来检索ApplicationForm实体,其中包含一个特定语言环境的字典,例如“it”。
filters
Hibernate具有应用
在你的数据上的任意过滤器。
在给定的会话中。首先,你需要
@org.hibernate.annotations.FilterDef
或
@FilterDefs
筛选器使用的定义
相同的名字。筛选器定义已存在
一
name()
parameters()
. 参数将允许
你需要调整
运行时筛选。每个参数都是
定义为
@ParamDef
名称和类型。您还可以定义
defaultCondition()
鉴于
@FilterDef
未定义时使用的条件
@Filter
. A
@过滤器def
(s) 可以在
类或包级别。
适用于实体的条款
加载或集合加载。
@过滤器
使用并放置在
实体或集合元素
@Entity
@FilterDef(name="minLength", parameters=@ParamDef( name="minLength", type="integer" ) )
@Filters( {
@Filter(name="betweenLength", condition=":minLength <= length and :maxLength >= length"),
@Filter(name="minLength", condition=":minLength <= length")
} )
public class Forest { ... }
当集合使用关联时
表作为关系表示,
您可能需要应用筛选器
自身或目标实体表。
实体,使用常规
@过滤器
以关联表为目标,使用
@FilterJoinTable
注释。
@OneToMany
@JoinTable
//filter on the target entity table
@Filter(name="betweenLength", condition=":minLength <= length and :maxLength >= length")
//filter on the association table
@FilterJoinTable(name="security", condition=":userlevel >= requredLevel")
public Set<Forest> getForests() { ... }