org.hibernate.criterion.Restrictions.sizeGe()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(3.2k)|赞(0)|评价(0)|浏览(87)

本文整理了Java中org.hibernate.criterion.Restrictions.sizeGe方法的一些代码示例,展示了Restrictions.sizeGe的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Restrictions.sizeGe方法的具体详情如下:
包路径:org.hibernate.criterion.Restrictions
类名称:Restrictions
方法名:sizeGe

Restrictions.sizeGe介绍

[英]Constrain a collection valued property by size
[中]按大小约束集合值属性

代码示例

代码示例来源:origin: org.grails/grails-datastore-gorm-hibernate-core

@Override
  public Criterion toHibernateCriterion(AbstractHibernateQuery hibernateQuery, Query.SizeGreaterThanEquals criterion, String alias) {
    String propertyName = getPropertyName(criterion, alias);
    Object value = criterion.getValue();
    int size = value instanceof Number ? ((Number)value).intValue() : Integer.parseInt(value.toString());
    return Restrictions.sizeGe(propertyName, size);
  }
});

代码示例来源:origin: org.grails/grails-hibernate

@Override
  public org.hibernate.criterion.Criterion toHibernateCriterion(HibernateQuery hibernateQuery, Query.Criterion criterion, String alias) {
    Query.SizeGreaterThanEquals eq = (Query.SizeGreaterThanEquals) criterion;
    return Restrictions.sizeGe(calculatePropertyName(eq.getProperty(), alias), (Integer) eq.getValue());
  }
});

代码示例来源:origin: org.grails/grails-hibernate

/**
 * Creates a Criterion that contrains a collection property to be greater than or equal to the given size
 *
 * @param propertyName The property name
 * @param size The size to constrain by
 *
 * @return A Criterion instance
 */
public org.grails.datastore.mapping.query.api.Criteria sizeGe(String propertyName, int size) {
  if (!validateSimpleExpression()) {
    throwRuntimeException(new IllegalArgumentException("Call to [sizeGe] with propertyName [" +
        propertyName + "] and size [" + size + "] not allowed here."));
  }
  propertyName = calculatePropertyName(propertyName);
  addToCriteria(Restrictions.sizeGe(propertyName, size));
  return this;
}

代码示例来源:origin: denimgroup/threadfix

private void addMinimumMergedFindings() {
  if (parameters.getNumberMerged() != null && parameters.getNumberMerged() > 0) {
    LOG.debug("Adding number merged = " + parameters.getNumberMerged());
    criteria.add(Restrictions.sizeGe("findings", parameters.getNumberMerged()));
  }
}

代码示例来源:origin: org.grails/grails-datastore-gorm-hibernate-core

/**
 * Creates a Criterion that contrains a collection property to be greater than or equal to the given size
 *
 * @param propertyName The property name
 * @param size The size to constrain by
 *
 * @return A Criterion instance
 */
public org.grails.datastore.mapping.query.api.Criteria sizeGe(String propertyName, int size) {
  if (!validateSimpleExpression()) {
    throwRuntimeException(new IllegalArgumentException("Call to [sizeGe] with propertyName [" +
        propertyName + "] and size [" + size + "] not allowed here."));
  }
  propertyName = calculatePropertyName(propertyName);
  addToCriteria(Restrictions.sizeGe(propertyName, size));
  return this;
}

代码示例来源:origin: dhis2/dhis2-core

@Override
public Criterion getHibernateCriterion( QueryPath queryPath )
{
  Property property = queryPath.getProperty();
  if ( property.isCollection() )
  {
    Integer value = QueryUtils.parseValue( Integer.class, args.get( 0 ) );
    if ( value == null )
    {
      throw new QueryException( "Left-side is collection, and right-side is not a valid integer, so can't compare by size." );
    }
    return Restrictions.sizeGe( queryPath.getPath(), value );
  }
  return Restrictions.ge( queryPath.getPath(), args.get( 0 ) );
}

相关文章