Java Code Examples for org.hibernate.type.AssociationType#isCollectionType()

The following examples show how to use org.hibernate.type.AssociationType#isCollectionType() . 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: JoinWalker.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Determine the appropriate associationType of join (if any) to use to fetch the
 * given association.
 *
 * @param associationType The association associationType.
 * @param config The metadata-defined fetch mode.
 * @param path The path to the association
 * @param lhsTable The owner table
 * @param lhsColumns The owner join columns
 * @param nullable Is the association nullable.
 * @param currentDepth Current join depth
 * @param cascadeStyle The metadata-defined cascade style.
 *
 * @return type of join to use ({@link org.hibernate.sql.JoinType#INNER_JOIN},
 * {@link org.hibernate.sql.JoinType#LEFT_OUTER_JOIN}, or -1 to indicate no joining.
 *
 * @throws MappingException ??
 */
protected JoinType getJoinType(
		AssociationType associationType,
		FetchMode config,
		PropertyPath path,
		String lhsTable,
		String[] lhsColumns,
		boolean nullable,
		int currentDepth,
		CascadeStyle cascadeStyle) throws MappingException {
	if ( !isJoinedFetchEnabled( associationType, config, cascadeStyle ) ) {
		return JoinType.NONE;
	}
	if ( isTooDeep( currentDepth ) || ( associationType.isCollectionType() && isTooManyCollections() ) ) {
		return JoinType.NONE;
	}
	if ( isDuplicateAssociation( lhsTable, lhsColumns, associationType ) ) {
		return JoinType.NONE;
	}
	return getJoinType( nullable, currentDepth );
}
 
Example 2
Source File: JoinWalker.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Does the mapping, and Hibernate default semantics, specify that
 * this association should be fetched by outer joining
 */
protected boolean isJoinedFetchEnabledInMapping(FetchMode config, AssociationType type)
		throws MappingException {
	if ( !type.isEntityType() && !type.isCollectionType() ) {
		return false;
	}
	else {
		if ( config == FetchMode.JOIN ) {
			return true;
		}
		if ( config == FetchMode.SELECT ) {
			return false;
		}
		if ( type.isEntityType() ) {
			//TODO: look at the owning property and check that it 
			//      isn't lazy (by instrumentation)
			EntityType entityType = (EntityType) type;
			EntityPersister persister = getFactory().getEntityPersister( entityType.getAssociatedEntityName() );
			return !persister.hasProxy();
		}
		else {
			return false;
		}
	}
}
 
Example 3
Source File: JoinWalker.java    From cacheonix-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Get the join type (inner, outer, etc) or -1 if the
 * association should not be joined. Override on
 * subclasses.
 */
protected int getJoinType(
		AssociationType type, 
		FetchMode config, 
		String path, 
		String lhsTable,
		String[] lhsColumns,
		boolean nullable,
		int currentDepth, 
		CascadeStyle cascadeStyle)
throws MappingException {
	
	if  ( !isJoinedFetchEnabled(type, config, cascadeStyle) ) return -1;
	
	if ( isTooDeep(currentDepth) || ( type.isCollectionType() && isTooManyCollections() ) ) return -1;
	
	final boolean dupe = isDuplicateAssociation(lhsTable,  lhsColumns, type);
	if (dupe) return -1;
	
	return getJoinType(nullable, currentDepth);
	
}
 
Example 4
Source File: JoinWalker.java    From cacheonix-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Does the mapping, and Hibernate default semantics, specify that
 * this association should be fetched by outer joining
 */
protected boolean isJoinedFetchEnabledInMapping(FetchMode config, AssociationType type) 
throws MappingException {
	if ( !type.isEntityType() && !type.isCollectionType() ) {
		return false;
	}
	else {
		if (config==FetchMode.JOIN) return true;
		if (config==FetchMode.SELECT) return false;
		if ( type.isEntityType() ) {
			//TODO: look at the owning property and check that it 
			//      isn't lazy (by instrumentation)
			EntityType entityType =(EntityType) type;
			EntityPersister persister = getFactory().getEntityPersister( entityType.getAssociatedEntityName() );
			return !persister.hasProxy();
		}
		else {
			return false;
		}
	}
}
 
Example 5
Source File: EntityJoinWalker.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
protected JoinType getJoinType(
		OuterJoinLoadable persister,
		PropertyPath path,
		int propertyNumber,
		AssociationType associationType,
		FetchMode metadataFetchMode,
		CascadeStyle metadataCascadeStyle,
		String lhsTable,
		String[] lhsColumns,
		boolean nullable,
		int currentDepth) throws MappingException {
	// NOTE : we override this form here specifically to account for
	// fetch profiles.
	// TODO : how to best handle criteria queries?
	if ( lockOptions.getLockMode().greaterThan( LockMode.READ ) ) {
		return JoinType.NONE;
	}
	if ( isTooDeep( currentDepth )
			|| ( associationType.isCollectionType() && isTooManyCollections() ) ) {
		return JoinType.NONE;
	}
	if ( !isJoinedFetchEnabledInMapping( metadataFetchMode, associationType )
			&& !isJoinFetchEnabledByProfile( persister, path, propertyNumber ) ) {
		return JoinType.NONE;
	}
	if ( isDuplicateAssociation( lhsTable, lhsColumns, associationType ) ) {
		return JoinType.NONE;
	}
	return getJoinType( nullable, currentDepth );
}
 
Example 6
Source File: CascadeEntityJoinWalker.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected boolean isJoinedFetchEnabled(AssociationType type, FetchMode config, CascadeStyle cascadeStyle) {
	return ( type.isEntityType() || type.isCollectionType() ) &&
			( cascadeStyle == null || cascadeStyle.doCascade( cascadeAction ) );
}
 
Example 7
Source File: CriteriaJoinWalker.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected JoinType getJoinType(
		OuterJoinLoadable persister,
		final PropertyPath path,
		int propertyNumber,
		AssociationType associationType,
		FetchMode metadataFetchMode,
		CascadeStyle metadataCascadeStyle,
		String lhsTable,
		String[] lhsColumns,
		final boolean nullable,
		final int currentDepth) throws MappingException {
	final JoinType resolvedJoinType;
	if ( translator.isJoin( path.getFullPath() ) ) {
		resolvedJoinType = translator.getJoinType( path.getFullPath() );
	}
	else {
		if ( translator.hasProjection() ) {
			resolvedJoinType = JoinType.NONE;
		}
		else {
			String fullPathWithAlias = path.getFullPath();
			String rootAlias = translator.getRootCriteria().getAlias();
			String rootAliasPathPrefix = rootAlias + ".";
			if (rootAlias != null && !fullPathWithAlias.startsWith(rootAliasPathPrefix)) {
				fullPathWithAlias = rootAliasPathPrefix + fullPathWithAlias;
			}

			FetchMode fetchMode = translator.getRootCriteria().getFetchMode( fullPathWithAlias );
			if ( isDefaultFetchMode( fetchMode ) ) {
				if ( persister != null ) {
					if ( isJoinFetchEnabledByProfile( persister, path, propertyNumber ) ) {
						if ( isDuplicateAssociation( lhsTable, lhsColumns, associationType ) ) {
							resolvedJoinType = JoinType.NONE;
						}
						else if ( isTooDeep( currentDepth ) || ( associationType.isCollectionType() && isTooManyCollections() ) ) {
							resolvedJoinType = JoinType.NONE;
						}
						else {
							resolvedJoinType = getJoinType( nullable, currentDepth );
						}
					}
					else {
						resolvedJoinType = super.getJoinType(
								persister,
								path,
								propertyNumber,
								associationType,
								metadataFetchMode,
								metadataCascadeStyle,
								lhsTable,
								lhsColumns,
								nullable,
								currentDepth
						);
					}
				}
				else {
					resolvedJoinType = super.getJoinType(
							associationType,
							metadataFetchMode,
							path,
							lhsTable,
							lhsColumns,
							nullable,
							currentDepth,
							metadataCascadeStyle
					);

				}
			}
			else {
				if ( fetchMode == FetchMode.JOIN ) {
					isDuplicateAssociation(
							lhsTable,
							lhsColumns,
							associationType
					); //deliberately ignore return value!
					resolvedJoinType = getJoinType( nullable, currentDepth );
				}
				else {
					resolvedJoinType = JoinType.NONE;
				}
			}
		}
	}
	return resolvedJoinType;
}
 
Example 8
Source File: CascadeEntityJoinWalker.java    From cacheonix-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
protected boolean isJoinedFetchEnabled(AssociationType type, FetchMode config, CascadeStyle cascadeStyle) {
	return ( type.isEntityType() || type.isCollectionType() ) &&
			( cascadeStyle==null || cascadeStyle.doCascade(cascadeAction) );
}