@@ -63,15 +63,38 @@ public class Forest { ... }</programlisting>
63
63
<title >Using <classname >@FilterJoinTable</classname > for filterting on
64
64
the association table</title >
65
65
66
- <programlisting language =" JAVA" role =" JAVA" > @OneToMany
67
- @JoinTable
68
- //filter on the target entity table
69
- @Filter(name="betweenLength", condition=":minLength < = length and :maxLength > = length")
70
- //filter on the association table
71
- @FilterJoinTable(name="security", condition=":userlevel > = requredLevel")
72
- public Set< Forest> getForests() { ... }</programlisting >
66
+ <programlisting language =" JAVA" role =" JAVA" >@OneToMany
67
+ @JoinTable
68
+ //filter on the target entity table
69
+ @Filter(name="betweenLength", condition=":minLength < = length and :maxLength > = length")
70
+ //filter on the association table
71
+ @FilterJoinTable(name="security", condition=":userlevel > = requredLevel")
72
+ public Set< Forest> getForests() { ... }</programlisting >
73
73
</example >
74
74
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 > = 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
+
75
98
<para >Using Hibernate mapping files for defining filters the situtation is
76
99
very similar. The filters must first be defined and then attached to the
77
100
appropriate mapping elements. To define a filter, use the
0 commit comments