Java Code Examples for org.hibernate.internal.CriteriaImpl#Subcriteria

The following examples show how to use org.hibernate.internal.CriteriaImpl#Subcriteria . 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: CriteriaQueryTranslator.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
private void createAssociationPathCriteriaMap() {
	final Iterator<CriteriaImpl.Subcriteria> iter = rootCriteria.iterateSubcriteria();
	while ( iter.hasNext() ) {
		CriteriaImpl.Subcriteria crit = iter.next();
		String wholeAssociationPath = getWholeAssociationPath( crit );
		Object old = associationPathCriteriaMap.put( wholeAssociationPath, crit );
		if ( old != null ) {
			throw new QueryException( "duplicate association path: " + wholeAssociationPath );
		}
		JoinType joinType = crit.getJoinType();
		old = associationPathJoinTypesMap.put( wholeAssociationPath, joinType );
		if ( old != null ) {
			// TODO : not so sure this is needed...
			throw new QueryException( "duplicate association path: " + wholeAssociationPath );
		}
		if ( crit.getWithClause() != null ) {
			this.withClauseMap.put( wholeAssociationPath, crit.getWithClause() );
		}
	}
}
 
Example 2
Source File: SubqueryExpression.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
private SharedSessionContractImplementor deriveRootSession(Criteria criteria) {
	if ( criteria instanceof CriteriaImpl ) {
		return ( (CriteriaImpl) criteria ).getSession();
	}
	else if ( criteria instanceof CriteriaImpl.Subcriteria ) {
		return deriveRootSession( ( (CriteriaImpl.Subcriteria) criteria ).getParent() );
	}
	else {
		// could happen for custom Criteria impls.  Not likely, but...
		// 		for long term solution, see HHH-3514
		return null;
	}
}
 
Example 3
Source File: CriteriaQueryTranslator.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
private void createAliasCriteriaMap() {
	aliasCriteriaMap.put( rootCriteria.getAlias(), rootCriteria );
	Iterator<CriteriaImpl.Subcriteria> iter = rootCriteria.iterateSubcriteria();
	while ( iter.hasNext() ) {
		Criteria subcriteria = iter.next();
		if ( subcriteria.getAlias() != null ) {
			Object old = aliasCriteriaMap.put( subcriteria.getAlias(), subcriteria );
			if ( old != null ) {
				throw new QueryException( "duplicate alias: " + subcriteria.getAlias() );
			}
		}
	}
}
 
Example 4
Source File: CriteriaQueryTranslator.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
private String getWholeAssociationPath(CriteriaImpl.Subcriteria subcriteria) {
	String path = subcriteria.getPath();

	// some messy, complex stuff here, since createCriteria() can take an
	// aliased path, or a path rooted at the creating criteria instance
	Criteria parent = null;
	if ( path.indexOf( '.' ) > 0 ) {
		// if it is a compound path
		String testAlias = StringHelper.root( path );
		if ( !testAlias.equals( subcriteria.getAlias() ) ) {
			// and the qualifier is not the alias of this criteria
			// -> check to see if we belong to some criteria other
			//  than the one that created us
			parent = aliasCriteriaMap.get( testAlias );
		}
	}
	if ( parent == null ) {
		// otherwise assume the parent is the the criteria that created us
		parent = subcriteria.getParent();
	}
	else {
		path = StringHelper.unroot( path );
	}

	if ( parent.equals( rootCriteria ) ) {
		// if its the root criteria, we are done
		return path;
	}
	else {
		// otherwise, recurse
		return getWholeAssociationPath( ( CriteriaImpl.Subcriteria ) parent ) + '.' + path;
	}
}
 
Example 5
Source File: CriteriaQueryTranslator.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
public boolean hasRestriction(String path) {
	final CriteriaImpl.Subcriteria subcriteria = (CriteriaImpl.Subcriteria) getCriteria( path );
	return subcriteria != null && subcriteria.hasRestriction();
}