Hibernate ORM DetachedCriteria - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Hibernate ORM DetachedCriteria class.

This code example shows how to use the following methods:getAlias, setProjection
	public DynamicQuery setProjection( 
		Projection projection, boolean useColumnAlias) {
 
		if (!useColumnAlias) {
			projection = ProjectionFactoryUtil.sqlProjection( 
				_detachedCriteria.getAlias() + "_." + projection.toString(),
				null, null); 
		} 
 
		ProjectionImpl projectionImpl = (ProjectionImpl)projection;
 
		_detachedCriteria.setProjection(projectionImpl.getWrappedProjection());
 
		return this;
	} 
 
	@Override 
	public String toString() {
		if (_criteria != null) {
			return _criteria.toString();
7
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
See Code Examples for Hibernate ORM DetachedCriteria Methods: