本文整理了Java中javax.persistence.criteria.Predicate
类的一些代码示例,展示了Predicate
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Predicate
类的具体详情如下:
包路径:javax.persistence.criteria.Predicate
类名称:Predicate
[英]The type of a simple or compound predicate: a conjunction or disjunction of restrictions. A simple predicate is considered to be a conjunction with a single conjunct.
[中]简单谓词或复合谓词的类型:限制的连接或分离。简单谓词被认为是带有单个连接词的连接词。
代码示例来源:origin: hibernate/hibernate-orm
@Override
public Predicate isNotNull(Expression<?> x) {
return isNull( x ).not();
}
代码示例来源:origin: Impetus/Kundera
List<Expression<Boolean>> expressions = where.getExpressions();
for (Expression expr : expressions)
代码示例来源:origin: FINRAOS/herd
@Test
public void testGetPredicateForInClauseTwoChunks()
{
// Create the JPA builder, query, and entity root.
CriteriaBuilder builder = entityManager.getCriteriaBuilder();
CriteriaQuery<BusinessObjectDataEntity> criteria = builder.createQuery(BusinessObjectDataEntity.class);
Root<BusinessObjectDataEntity> businessObjectDataEntity = criteria.from(BusinessObjectDataEntity.class);
// Get the predicate for the "in" clause with 1001 values (1 greater than the default chunking size).
Predicate predicate = baseJpaDaoImpl
.getPredicateForInClause(builder, businessObjectDataEntity.get(BusinessObjectDataEntity_.partitionValue), getPartitionValueList(1001));
// We expect to get back an "or" of 2 "in" expressions where each "in" expression is a list of chunked partition values.
assertEquals(Predicate.BooleanOperator.OR, predicate.getOperator());
List<Expression<Boolean>> expressions = predicate.getExpressions();
assertEquals(2, expressions.size());
// The first "in" clause will have the first 1000 elements and the second "in" clause will have the extra "1" element.
assertEquals(1000, ((InPredicate) expressions.get(0)).getValues().size());
assertEquals(1, ((InPredicate) expressions.get(1)).getValues().size());
}
代码示例来源:origin: com.haulmont.thirdparty/eclipselink
/**
* Create a predicate testing for a false value.
*
* @param x
* expression to be tested if false
* @return predicate
*/
public Predicate isFalse(Expression<Boolean> x){
if (((InternalExpression)x).isPredicate()){
if (((InternalSelection)x).getCurrentNode() == null){
if (((Predicate)x).getOperator() == BooleanOperator.AND){
return (Predicate)x;
}else{
return this.conjunction();
}
}else{
throw new IllegalArgumentException(ExceptionLocalization.buildMessage("PREDICATE_PASSED_TO_EVALUATION"));
}
}
return new CompoundExpressionImpl(this.metamodel, ((InternalSelection)x).getCurrentNode().equal(false), buildList(x), "equals");
}
代码示例来源:origin: stackoverflow.com
private Specification<Event> buildSpecification(final EventFilter filter) {
final Specification<Event> specification = new Specification<Event>() {
@Override
public Predicate toPredicate(Root<Event> root, CriteriaQuery<?> cq, CriteriaBuilder cb) {
cq.distinct(true);
Predicate predicate = cb.conjunction();
if (filter.getEventGroupIds() != null) {
Join<Event, EventGroup> join = root.join(Event_.eventGroups);
predicate.getExpressions().add(join.get(EventGroup_.id).in(filter.getEventGroupIds()) );
}
return predicate;
}
};
return specification;
}
代码示例来源:origin: hibernate/hibernate-orm
@Override
public Predicate notLike(Expression<String> matchExpression, Expression<String> pattern, char escapeCharacter) {
return like( matchExpression, pattern, escapeCharacter ).not();
}
代码示例来源:origin: dhis2/dhis2-core
@Override
public int count( DeletedObjectQuery query )
{
CriteriaBuilder builder = getCurrentSession().getCriteriaBuilder();
CriteriaQuery<Long> criteriaQuery = builder.createQuery( Long.class );
Root<DeletedObject> root = criteriaQuery.from( DeletedObject.class );
Predicate predicate = buildCriteria( builder, root, query );
criteriaQuery.select( builder.countDistinct( root ) );
if ( !predicate.getExpressions().isEmpty() ) criteriaQuery.where( predicate );
Query<Long> typedQuery = getCurrentSession().createQuery( criteriaQuery );
return typedQuery.getSingleResult().intValue();
}
代码示例来源:origin: hibernate/hibernate-orm
@Override
public Predicate notLike(Expression<String> matchExpression, String pattern, Expression<Character> escapeCharacter) {
return like( matchExpression, pattern, escapeCharacter ).not();
}
代码示例来源:origin: dhis2/dhis2-core
disjunction.getExpressions().add( root.get( "uid" ).in( query.getUid() ) );
disjunction.getExpressions().add( root.get( "code" ).in( query.getCode() ) );
if ( !disjunction.getExpressions().isEmpty() ) predicate.getExpressions().add( disjunction );
predicate.getExpressions().add( builder.or( root.get( "klass" ).in( query.getKlass() ),
root.get( "klass" ).in( query.getKlass() ) ) );
conjunction.getExpressions().add( root.get( "klass" ).in( query.getKlass() ) );
conjunction.getExpressions().add( root.get( "uid" ).in( query.getUid() ) );
disjunction.getExpressions().add( conjunction );
conjunction.getExpressions().add( root.get( "klass" ).in( query.getKlass() ) );
conjunction.getExpressions().add( root.get( "code" ).in( query.getUid() ) );
disjunction.getExpressions().add( conjunction );
if ( !disjunction.getExpressions().isEmpty() ) predicate.getExpressions().add( disjunction );
predicate.getExpressions().add( builder.greaterThanOrEqualTo( root.get( "deletedAt" ), query.getDeletedAt() ) );
代码示例来源:origin: hibernate/hibernate-orm
@Override
public <C extends Collection<?>> Predicate isNotEmpty(Expression<C> collectionExpression) {
return isEmpty( collectionExpression ).not();
}
代码示例来源:origin: stackoverflow.com
if(whereClause.getExpressions().isEmpty()) {
throw new RuntimeException("no criteria");
代码示例来源:origin: hibernate/hibernate-orm
@Override
public Predicate not(Expression<Boolean> expression) {
return wrap( expression ).not();
}
代码示例来源:origin: dhis2/dhis2-core
conjunction.getExpressions().add( predicate );
代码示例来源:origin: hibernate/hibernate-orm
@Override
public <E, C extends Collection<E>> Predicate isNotMember(E e, Expression<C> cExpression) {
return isMember(e, cExpression).not();
}
代码示例来源:origin: dhis2/dhis2-core
@Override
public List<DeletedObject> query( DeletedObjectQuery query )
{
CriteriaBuilder builder = getCurrentSession().getCriteriaBuilder();
CriteriaQuery<DeletedObject> criteriaQuery = builder.createQuery( DeletedObject.class );
Root<DeletedObject> root = criteriaQuery.from( DeletedObject.class );
Predicate predicate = buildCriteria( builder, root, query );
criteriaQuery.select( root );
if ( !predicate.getExpressions().isEmpty() ) criteriaQuery.where( predicate );
Query<DeletedObject> typedQuery = getCurrentSession().createQuery( criteriaQuery );
if ( !query.isSkipPaging() )
{
Pager pager = query.getPager();
typedQuery.setFirstResult( pager.getOffset() );
typedQuery.setMaxResults( pager.getPageSize() );
}
return typedQuery.list();
}
代码示例来源:origin: hibernate/hibernate-orm
@Override
public <E, C extends Collection<E>> Predicate isNotMember(Expression<E> eExpression, Expression<C> cExpression) {
return isMember(eExpression, cExpression).not();
}
代码示例来源:origin: org.picketlink/picketlink-idm-impl
conjunction.getExpressions().add(
builder.or(builder.greaterThanOrEqualTo(root.<Date> get(expiryProperty.getName()), new Date()),
builder.isNull(root.<Date> get(expiryProperty.getName()))));
代码示例来源:origin: hibernate/hibernate-orm
@Override
public <M extends Map<?, ?>> Predicate isMapNotEmpty(Expression<M> mapExpression) {
return isMapEmpty( mapExpression ).not();
}
代码示例来源:origin: dhis2/dhis2-core
disjunction.getExpressions().add( root.get( "uid" ).in( query.getUid() ) );
disjunction.getExpressions().add( root.get( "code" ).in( query.getCode() ) );
disjunction.getExpressions().add( conjunction );
disjunction.getExpressions().add( conjunction );
代码示例来源:origin: hibernate/hibernate-orm
@Override
public Predicate notLike(Expression<String> matchExpression, Expression<String> pattern) {
return like( matchExpression, pattern ).not();
}
内容来源于网络,如有侵权,请联系作者删除!