Skip to content

Commit f9aa6e6

Browse files
author
Chris Cranford
committed
HHH-11737 - Remove dependency on org.hibernate.criterion package.
1 parent 5ff2289 commit f9aa6e6

File tree

4 files changed

+72
-6
lines changed

4 files changed

+72
-6
lines changed

hibernate-envers/src/main/java/org/hibernate/envers/query/AuditEntity.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,7 @@
2323
import org.hibernate.envers.query.projection.internal.EntityAuditProjection;
2424

2525
/**
26-
* TODO: ilike
27-
*
2826
* @author Adam Warski (adam at warski dot org)
29-
*
30-
* @see org.hibernate.criterion.Restrictions
3127
*/
3228
@SuppressWarnings({"JavaDoc"})
3329
public class AuditEntity {

hibernate-envers/src/main/java/org/hibernate/envers/query/criteria/AuditProperty.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
import java.util.Collection;
1010

11-
import org.hibernate.criterion.MatchMode;
1211
import org.hibernate.envers.boot.internal.EnversService;
1312
import org.hibernate.envers.internal.entities.EntityInstantiator;
1413
import org.hibernate.envers.query.criteria.internal.BetweenAuditExpression;
@@ -86,7 +85,16 @@ public AuditCriterion ilike(T value) {
8685

8786
/**
8887
* Apply an "ilike" constraint
88+
* @deprecated since 5.2, use {@link #ilike(String, MatchMode)}. To be removed in 6.0.
8989
*/
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+
*/
9098
public AuditCriterion ilike(String value, MatchMode matchMode) {
9199
return new IlikeAuditExpression( alias, propertyNameGetter, matchMode.toMatchString( value ) );
92100
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
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+
}

hibernate-envers/src/test/java/org/hibernate/envers/test/integration/query/SimpleQuery.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
import java.util.List;
1212
import javax.persistence.EntityManager;
1313

14-
import org.hibernate.criterion.MatchMode;
1514
import org.hibernate.envers.RevisionType;
1615
import org.hibernate.envers.enhanced.SequenceIdRevisionEntity;
1716
import org.hibernate.envers.query.AuditEntity;
17+
import org.hibernate.envers.query.criteria.MatchMode;
1818
import org.hibernate.envers.test.BaseEnversJPAFunctionalTestCase;
1919
import org.hibernate.envers.test.Priority;
2020
import org.hibernate.envers.test.entities.StrIntTestEntity;

0 commit comments

Comments
 (0)