Skip to content

Commit

Permalink
HHH-11737 - Remove dependency on org.hibernate.criterion package.
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Cranford committed May 10, 2017
1 parent 5ff2289 commit f9aa6e6
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 6 deletions.
Expand Up @@ -23,11 +23,7 @@
import org.hibernate.envers.query.projection.internal.EntityAuditProjection;

/**
* TODO: ilike
*
* @author Adam Warski (adam at warski dot org)
*
* @see org.hibernate.criterion.Restrictions
*/
@SuppressWarnings({"JavaDoc"})
public class AuditEntity {
Expand Down
Expand Up @@ -8,7 +8,6 @@

import java.util.Collection;

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

/**
* Apply an "ilike" constraint
* @deprecated since 5.2, use {@link #ilike(String, MatchMode)}. To be removed in 6.0.
*/
@Deprecated
public AuditCriterion ilike(String value, org.hibernate.criterion.MatchMode matchMode) {
return new IlikeAuditExpression( alias, propertyNameGetter, matchMode.toMatchString( value ) );
}

/**
* Apply on "ilike" constraint
*/
public AuditCriterion ilike(String value, MatchMode matchMode) {
return new IlikeAuditExpression( alias, propertyNameGetter, matchMode.toMatchString( value ) );
}
Expand Down
@@ -0,0 +1,62 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.envers.query.criteria;

/**
* A strategy for matching strings using "like".
*
* @author Chris Cranford
*/
public enum MatchMode {
/**
* Match the pattern exactly.
*/
EXACT {
@Override
public String toMatchString(String pattern) {
return pattern;
}
},

/**
* Match the start of the string to the pattern.
*/
START {
@Override
public String toMatchString(String pattern) {
return pattern + '%';
}
},

/**
* Match the end of the string to the pattern.
*/
END {
@Override
public String toMatchString(String pattern) {
return '%' + pattern;
}
},

/**
* Match the pattern anywhere in the string.
*/
ANYWHERE {
@Override
public String toMatchString(String pattern) {
return '%' + pattern + '%';
}
};

/**
* Convert the pattern by prepending/append "%".
*
* @param pattern The pattern to convert according to the mode.
* @return The converted pattern.
*/
public abstract String toMatchString(String pattern);
}
Expand Up @@ -11,10 +11,10 @@
import java.util.List;
import javax.persistence.EntityManager;

import org.hibernate.criterion.MatchMode;
import org.hibernate.envers.RevisionType;
import org.hibernate.envers.enhanced.SequenceIdRevisionEntity;
import org.hibernate.envers.query.AuditEntity;
import org.hibernate.envers.query.criteria.MatchMode;
import org.hibernate.envers.test.BaseEnversJPAFunctionalTestCase;
import org.hibernate.envers.test.Priority;
import org.hibernate.envers.test.entities.StrIntTestEntity;
Expand Down

0 comments on commit f9aa6e6

Please sign in to comment.