
org.hibernate.jpa.criteria.predicate.MemberOfPredicate Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hibernate-entitymanager
Show all versions of hibernate-entitymanager
A module of the Hibernate O/RM project
/*
* 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 .
*/
package org.hibernate.jpa.criteria.predicate;
import java.io.Serializable;
import java.util.Collection;
import javax.persistence.criteria.Expression;
import org.hibernate.jpa.criteria.CriteriaBuilderImpl;
import org.hibernate.jpa.criteria.ParameterRegistry;
import org.hibernate.jpa.criteria.Renderable;
import org.hibernate.jpa.criteria.compile.RenderingContext;
import org.hibernate.jpa.criteria.expression.LiteralExpression;
import org.hibernate.jpa.criteria.path.PluralAttributePath;
/**
* Models an [NOT] MEMBER OF restriction
*
* @author Steve Ebersole
*/
public class MemberOfPredicate>
extends AbstractSimplePredicate
implements Serializable {
private final Expression elementExpression;
private final PluralAttributePath collectionPath;
public MemberOfPredicate(
CriteriaBuilderImpl criteriaBuilder,
Expression elementExpression,
PluralAttributePath collectionPath) {
super( criteriaBuilder );
this.elementExpression = elementExpression;
this.collectionPath = collectionPath;
}
public MemberOfPredicate(
CriteriaBuilderImpl criteriaBuilder,
E element,
PluralAttributePath collectionPath) {
this(
criteriaBuilder,
new LiteralExpression( criteriaBuilder, element ),
collectionPath
);
}
public PluralAttributePath getCollectionPath() {
return collectionPath;
}
public Expression getElementExpression() {
return elementExpression;
}
@Override
public void registerParameters(ParameterRegistry registry) {
Helper.possibleParameter( getCollectionPath(), registry );
Helper.possibleParameter( getElementExpression(), registry );
}
@Override
public String render(boolean isNegated, RenderingContext renderingContext) {
return ( (Renderable) elementExpression ).render( renderingContext )
+ ( isNegated ? " not" : "" ) + " member of "
+ getCollectionPath().render( renderingContext );
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy