本文整理了Java中org.hibernate.criterion.Restrictions.sizeLe
方法的一些代码示例,展示了Restrictions.sizeLe
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Restrictions.sizeLe
方法的具体详情如下:
包路径:org.hibernate.criterion.Restrictions
类名称: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 ) );
}
内容来源于网络,如有侵权,请联系作者删除!