Java Code Examples for org.hibernate.criterion.Restrictions#between()

The following examples show how to use org.hibernate.criterion.Restrictions#between() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CriteriaQuery.java    From jeewx with Apache License 2.0 5 votes vote down vote up
/**
 * 设置between(之间)查询条件
 * 
 * @param keyname
 * @param keyvalue1
 * @param keyvalue2
 */
public void between(String keyname, Object keyvalue1, Object keyvalue2) {
	Criterion c = null;// 写入between查询条件

	if (!keyvalue1.equals(null) && !keyvalue2.equals(null)) {
		c = Restrictions.between(keyname, keyvalue1, keyvalue2);
	} else if (!keyvalue1.equals(null)) {
		c = Restrictions.ge(keyname, keyvalue1);
	} else if (!keyvalue2.equals(null)) {
		c = Restrictions.le(keyname, keyvalue2);
	}
	criterionList.add(c);
}
 
Example 2
Source File: CriteriaVisitor.java    From geomajas-project-server with GNU Affero General Public License v3.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
public Object visit(PropertyIsBetween filter, Object userData) {
	String propertyName = getPropertyName(filter.getExpression());
	String finalName = parsePropertyName(propertyName, userData);

	Object lo = castLiteral(getLiteralValue(filter.getLowerBoundary()), propertyName);
	Object hi = castLiteral(getLiteralValue(filter.getUpperBoundary()), propertyName);
	return Restrictions.between(finalName, lo, hi);
}
 
Example 3
Source File: CriteriaVisitor.java    From geomajas-project-server with GNU Affero General Public License v3.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
public Object visit(During during, Object userData) {
	String propertyName = getPropertyName(during.getExpression1());
	String finalName = parsePropertyName(propertyName, userData);
	Object literal = getLiteralValue(during.getExpression2());
	if (literal instanceof Period) {
		Period p = (Period) literal;
		Date begin = p.getBeginning().getPosition().getDate();
		Date end = p.getEnding().getPosition().getDate();
		return Restrictions.between(finalName, begin, end);
	} else {
		throw new UnsupportedOperationException("visit(Object userData)");
	}
}
 
Example 4
Source File: CriteriaQuery.java    From jeecg with Apache License 2.0 5 votes vote down vote up
/**
 * 设置between(之间)查询条件
 * 
 * @param keyname
 * @param keyvalue1
 * @param keyvalue2
 */
public void between(String keyname, Object keyvalue1, Object keyvalue2) {
	Criterion c = null;// 写入between查询条件

	if (oConvertUtils.isNotEmpty(keyvalue1) && oConvertUtils.isNotEmpty(keyvalue2)) {
		c = Restrictions.between(keyname, keyvalue1, keyvalue2);
	} else if (oConvertUtils.isNotEmpty(keyvalue1)) {
		c = Restrictions.ge(keyname, keyvalue1);
	} else if (oConvertUtils.isNotEmpty(keyvalue2)) {
		c = Restrictions.le(keyname, keyvalue2);
	}
	criterionList.add(c);
}
 
Example 5
Source File: BetweenOperator.java    From dhis2-core with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public Criterion getHibernateCriterion( QueryPath queryPath )
{
    return Restrictions.between( queryPath.getPath(), args.get( 0 ), args.get( 1 ) );
}
 
Example 6
Source File: DateContainerFilter.java    From chipster with MIT License 4 votes vote down vote up
@Override
public Criterion getFieldCriterion(String fullPropertyName) {
	return Restrictions.between(fullPropertyName, searchDateStart, searchDateEnd);
}