File tree Expand file tree Collapse file tree 4 files changed +72
-6
lines changed
main/java/org/hibernate/envers/query
test/java/org/hibernate/envers/test/integration/query Expand file tree Collapse file tree 4 files changed +72
-6
lines changed Original file line number Diff line number Diff line change 23
23
import org .hibernate .envers .query .projection .internal .EntityAuditProjection ;
24
24
25
25
/**
26
- * TODO: ilike
27
- *
28
26
* @author Adam Warski (adam at warski dot org)
29
- *
30
- * @see org.hibernate.criterion.Restrictions
31
27
*/
32
28
@ SuppressWarnings ({"JavaDoc" })
33
29
public class AuditEntity {
Original file line number Diff line number Diff line change 8
8
9
9
import java .util .Collection ;
10
10
11
- import org .hibernate .criterion .MatchMode ;
12
11
import org .hibernate .envers .boot .internal .EnversService ;
13
12
import org .hibernate .envers .internal .entities .EntityInstantiator ;
14
13
import org .hibernate .envers .query .criteria .internal .BetweenAuditExpression ;
@@ -86,7 +85,16 @@ public AuditCriterion ilike(T value) {
86
85
87
86
/**
88
87
* Apply an "ilike" constraint
88
+ * @deprecated since 5.2, use {@link #ilike(String, MatchMode)}. To be removed in 6.0.
89
89
*/
90
+ @ Deprecated
91
+ public AuditCriterion ilike (String value , org .hibernate .criterion .MatchMode matchMode ) {
92
+ return new IlikeAuditExpression ( alias , propertyNameGetter , matchMode .toMatchString ( value ) );
93
+ }
94
+
95
+ /**
96
+ * Apply on "ilike" constraint
97
+ */
90
98
public AuditCriterion ilike (String value , MatchMode matchMode ) {
91
99
return new IlikeAuditExpression ( alias , propertyNameGetter , matchMode .toMatchString ( value ) );
92
100
}
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Hibernate, Relational Persistence for Idiomatic Java
3
+ *
4
+ * License: GNU Lesser General Public License (LGPL), version 2.1 or later.
5
+ * See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
6
+ */
7
+ package org .hibernate .envers .query .criteria ;
8
+
9
+ /**
10
+ * A strategy for matching strings using "like".
11
+ *
12
+ * @author Chris Cranford
13
+ */
14
+ public enum MatchMode {
15
+ /**
16
+ * Match the pattern exactly.
17
+ */
18
+ EXACT {
19
+ @ Override
20
+ public String toMatchString (String pattern ) {
21
+ return pattern ;
22
+ }
23
+ },
24
+
25
+ /**
26
+ * Match the start of the string to the pattern.
27
+ */
28
+ START {
29
+ @ Override
30
+ public String toMatchString (String pattern ) {
31
+ return pattern + '%' ;
32
+ }
33
+ },
34
+
35
+ /**
36
+ * Match the end of the string to the pattern.
37
+ */
38
+ END {
39
+ @ Override
40
+ public String toMatchString (String pattern ) {
41
+ return '%' + pattern ;
42
+ }
43
+ },
44
+
45
+ /**
46
+ * Match the pattern anywhere in the string.
47
+ */
48
+ ANYWHERE {
49
+ @ Override
50
+ public String toMatchString (String pattern ) {
51
+ return '%' + pattern + '%' ;
52
+ }
53
+ };
54
+
55
+ /**
56
+ * Convert the pattern by prepending/append "%".
57
+ *
58
+ * @param pattern The pattern to convert according to the mode.
59
+ * @return The converted pattern.
60
+ */
61
+ public abstract String toMatchString (String pattern );
62
+ }
Original file line number Diff line number Diff line change 11
11
import java .util .List ;
12
12
import javax .persistence .EntityManager ;
13
13
14
- import org .hibernate .criterion .MatchMode ;
15
14
import org .hibernate .envers .RevisionType ;
16
15
import org .hibernate .envers .enhanced .SequenceIdRevisionEntity ;
17
16
import org .hibernate .envers .query .AuditEntity ;
17
+ import org .hibernate .envers .query .criteria .MatchMode ;
18
18
import org .hibernate .envers .test .BaseEnversJPAFunctionalTestCase ;
19
19
import org .hibernate .envers .test .Priority ;
20
20
import org .hibernate .envers .test .entities .StrIntTestEntity ;
You can’t perform that action at this time.
0 commit comments