HHH-8790 added @Filter deduceAliasInjectionPoints info and examples to
user guide
This commit is contained in:
parent
2a90123991
commit
99a6fc07b6
|
@ -63,13 +63,36 @@ public class Forest { ... }</programlisting>
|
|||
<title>Using <classname>@FilterJoinTable</classname> for filterting on
|
||||
the association table</title>
|
||||
|
||||
<programlisting language="JAVA" role="JAVA"> @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() { ... }</programlisting>
|
||||
<programlisting language="JAVA" role="JAVA">@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() { ... }</programlisting>
|
||||
</example>
|
||||
|
||||
<para>By default, Hibernate attempts to automatically determine all points within the
|
||||
<literal>@Filter</literal> SQL condition fragment that an alias should be injected. To control the alias injection,
|
||||
set <literal>deduceAliasInjectionPoints</literal> to <literal>false</literal> within the
|
||||
<literal>@Filter</literal>. Injection points are then marked using <literal>@SqlFragmentAlias</literal> annotations or
|
||||
within the SQL's condition fragment using <literal>{alias}</literal>.</para>
|
||||
|
||||
<para>In addition to allowing explicit alias control, <literal>deduceAliasInjectionPoints</literal>
|
||||
provides an out when Hibernate assumes an ANSI SQL reserved keyword is a column and incorrectly aliases it.</para>
|
||||
|
||||
<example>
|
||||
<title>@Filter annotation, disabling deduceAliasInjectionPoints</title>
|
||||
|
||||
<programlisting language="JAVA" role="JAVA">@Entity
|
||||
@Table(name="T_TREE")
|
||||
@Filters({
|
||||
@Filter(name="isTall", condition="{alias}.LENGTH >= 100", deduceAliasInjectionPoints = false),
|
||||
@Filter(name="isOak", condition="{t}.WOODTYPE like 'oak'", deduceAliasInjectionPoints = false,
|
||||
aliases={@SqlFragmentAlias(alias="t", table="T_TREE")})
|
||||
})
|
||||
public class Tree { ... }
|
||||
</programlisting>
|
||||
</example>
|
||||
|
||||
<para>Using Hibernate mapping files for defining filters the situtation is
|
||||
|
|
Loading…
Reference in New Issue