DetachedCriteria add - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for DetachedCriteria add method.

This code example shows how to use the following methods:add
 
	@Override 
	public DynamicQuery add(Criterion criterion) {
		CriterionImpl criterionImpl = (CriterionImpl)criterion;
 
		_detachedCriteria.add(criterionImpl.getWrappedCriterion());
 
		return this;
	} 
 
	@Override 
	public DynamicQuery addOrder(Order order) {
		OrderImpl orderImpl = (OrderImpl)order;
 
		_detachedCriteria.addOrder(orderImpl.getWrappedOrder());
 
		return this;
	} 
 
	@Override 
6
CodeRank
This code example shows how to use the following methods:add, setProjection
	 */ 
	@SuppressWarnings("unchecked") 
	@Override 
	public List<Long> getRandomIds(Integer maxResults) {
		DetachedCriteria criteria = this.createDetachedCriteria();
		criteria.setProjection(Projections.id());
		criteria.add(getRandomRestriction());
		return this.getHibernateTemplate().findByCriteria(criteria, 0, maxResults);
	} 
	 
	/** 
	 * Find random results that fulfill the given criteria. 
	 *  
	 * @param criteria The {@link DetachedCriteria} to fulfill. 
	 * @param maxResults Maximum quantity of results to find. 
	 * @return The random list. 
	 */ 
	protected List<T> findRandomList(DetachedCriteria criteria, Integer maxResults) {
		criteria.add(getRandomRestriction());
		return find(criteria, maxResults);
5
CodeRank
This code example shows how to use the following methods:add
	 * @see com.jdroid.javaweb.push.DeviceRepository#find(java.lang.String, com.jdroid.javaweb.push.DeviceType) 
	 */ 
	@Override 
	public Device find(String deviceId, DeviceType deviceType) {
		DetachedCriteria criteria = createDetachedCriteria();
		criteria.add(Restrictions.eq("deviceId", deviceId));
		criteria.add(Restrictions.eq("deviceType", deviceType));
		return this.findUnique(criteria);
	} 
	 
	/** 
	 * @see com.jdroid.javaweb.push.DeviceRepository#find(java.lang.String, com.jdroid.javaweb.push.DeviceType, 
	 *      java.lang.String) 
	 */ 
	@Override 
	public Device find(String deviceId, DeviceType deviceType, String registrationId) {
		DetachedCriteria criteria = createDetachedCriteria();
		criteria.add(Restrictions.eq("deviceId", deviceId));
		criteria.add(Restrictions.eq("deviceType", deviceType));
		criteria.add(Restrictions.eq("registrationId", registrationId));
4
CodeRank
add Method Overview
Add a restriction
See Code Examples for other Hibernate ORM DetachedCriteria Methods: