Skip to content

Commit 99a6fc0

Browse files
committed
HHH-8790 added @filter deduceAliasInjectionPoints info and examples to
user guide
1 parent 2a90123 commit 99a6fc0

File tree

1 file changed

+30
-7
lines changed
  • documentation/src/main/docbook/manual/en-US/content

1 file changed

+30
-7
lines changed

documentation/src/main/docbook/manual/en-US/content/filters.xml

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,38 @@ public class Forest { ... }</programlisting>
6363
<title>Using <classname>@FilterJoinTable</classname> for filterting on
6464
the association table</title>
6565

66-
<programlisting language="JAVA" role="JAVA"> @OneToMany
67-
@JoinTable
68-
//filter on the target entity table
69-
@Filter(name="betweenLength", condition=":minLength &lt;= length and :maxLength &gt;= length")
70-
//filter on the association table
71-
@FilterJoinTable(name="security", condition=":userlevel &gt;= requredLevel")
72-
public Set&lt;Forest&gt; getForests() { ... }</programlisting>
66+
<programlisting language="JAVA" role="JAVA">@OneToMany
67+
@JoinTable
68+
//filter on the target entity table
69+
@Filter(name="betweenLength", condition=":minLength &lt;= length and :maxLength &gt;= length")
70+
//filter on the association table
71+
@FilterJoinTable(name="security", condition=":userlevel &gt;= requredLevel")
72+
public Set&lt;Forest&gt; getForests() { ... }</programlisting>
7373
</example>
7474

75+
<para>By default, Hibernate attempts to automatically determine all points within the
76+
<literal>@Filter</literal> SQL condition fragment that an alias should be injected. To control the alias injection,
77+
set <literal>deduceAliasInjectionPoints</literal> to <literal>false</literal> within the
78+
<literal>@Filter</literal>. Injection points are then marked using <literal>@SqlFragmentAlias</literal> annotations or
79+
within the SQL's condition fragment using <literal>{alias}</literal>.</para>
80+
81+
<para>In addition to allowing explicit alias control, <literal>deduceAliasInjectionPoints</literal>
82+
provides an out when Hibernate assumes an ANSI SQL reserved keyword is a column and incorrectly aliases it.</para>
83+
84+
<example>
85+
<title>@Filter annotation, disabling deduceAliasInjectionPoints</title>
86+
87+
<programlisting language="JAVA" role="JAVA">@Entity
88+
@Table(name="T_TREE")
89+
@Filters({
90+
@Filter(name="isTall", condition="{alias}.LENGTH &gt;= 100", deduceAliasInjectionPoints = false),
91+
@Filter(name="isOak", condition="{t}.WOODTYPE like 'oak'", deduceAliasInjectionPoints = false,
92+
aliases={@SqlFragmentAlias(alias="t", table="T_TREE")})
93+
})
94+
public class Tree { ... }
95+
</programlisting>
96+
</example>
97+
7598
<para>Using Hibernate mapping files for defining filters the situtation is
7699
very similar. The filters must first be defined and then attached to the
77100
appropriate mapping elements. To define a filter, use the

0 commit comments

Comments
 (0)