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

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

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

Restrictions.sizeLe介绍

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

代码示例

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

@Override
  public Criterion toHibernateCriterion(AbstractHibernateQuery hibernateQuery, Query.SizeLessThanEquals 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.sizeLe(propertyName, size);
  }
});

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

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

代码示例来源:origin: riotfamily/riot

@SuppressWarnings("unchecked")
public static void removeEmptyEntries(String bundle) {
  List<MessageBundleEntry> entries = getSession().createCriteria(MessageBundleEntry.class)
    .setCacheable(true)
    .setCacheRegion("messages")
    .add(Restrictions.sizeLe("messages", 1))
    .add(Restrictions.naturalId()
      .set("bundle", bundle))
      .list();
  
  for (MessageBundleEntry entry : entries) {
    entry.delete();
  }
}

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

/**
 * Creates a Criterion that contrains a collection property to be less 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 sizeLe(String propertyName, int size) {
  if (!validateSimpleExpression()) {
    throwRuntimeException(new IllegalArgumentException("Call to [sizeLe] with propertyName [" +
        propertyName + "] and size [" + size + "] not allowed here."));
  }
  propertyName = calculatePropertyName(propertyName);
  addToCriteria(Restrictions.sizeLe(propertyName, size));
  return this;
}

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

/**
 * Creates a Criterion that contrains a collection property to be less 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 sizeLe(String propertyName, int size) {
  if (!validateSimpleExpression()) {
    throwRuntimeException(new IllegalArgumentException("Call to [sizeLe] with propertyName [" +
        propertyName + "] and size [" + size + "] not allowed here."));
  }
  propertyName = calculatePropertyName(propertyName);
  addToCriteria(Restrictions.sizeLe(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.sizeLe( queryPath.getPath(), value );
  }
  return Restrictions.le( queryPath.getPath(), args.get( 0 ) );
}

相关文章