Java Code Examples for org.hibernate.persister.collection.SQLLoadableCollection

The following examples show how to use org.hibernate.persister.collection.SQLLoadableCollection. These examples are extracted from open source projects. 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 Project: lams   Source File: ColumnCollectionAliases.java    License: GNU General Public License v2.0 6 votes vote down vote up
public ColumnCollectionAliases(Map userProvidedAliases, SQLLoadableCollection persister) {
	this.userProvidedAliases = userProvidedAliases;

	this.keyAliases = getUserProvidedAliases(
			"key",
			persister.getKeyColumnNames()
	);

	this.indexAliases = getUserProvidedAliases(
			"index",
			persister.getIndexColumnNames()
	);

	this.elementAliases = getUserProvidedAliases(
			"element",
			persister.getElementColumnNames()
	);

	this.identifierAlias = getUserProvidedAlias(
			"id",
			persister.getIdentifierColumnName()
	);

}
 
Example 2
public ColumnCollectionAliases(Map userProvidedAliases, SQLLoadableCollection persister) {
	this.userProvidedAliases = userProvidedAliases;

	this.keyAliases = getUserProvidedAliases(
			"key", 
			persister.getKeyColumnNames()
		);

	this.indexAliases = getUserProvidedAliases(
			"index",
			persister.getIndexColumnNames()
			);
	
	this.elementAliases = getUserProvidedAliases( "element", 
			persister.getElementColumnNames()
			);
			
	this.identifierAlias = getUserProvidedAlias( "id", 
			persister.getIdentifierColumnName()
			);

}
 
Example 3
Source Project: lams   Source File: SQLQueryReturnProcessor.java    License: GNU General Public License v2.0 5 votes vote down vote up
private void addCollection(String role, String alias, Map propertyResults) {
	SQLLoadableCollection collectionPersister = ( SQLLoadableCollection ) factory.getCollectionPersister( role );
	alias2CollectionPersister.put( alias, collectionPersister );
	String suffix = generateCollectionSuffix();
	LOG.tracev( "Mapping alias [{0}] to collection-suffix [{1}]", alias, suffix );
	alias2CollectionSuffix.put( alias, suffix );
	collectionPropertyResultMaps.put( alias, propertyResults );

	if ( collectionPersister.isOneToMany() || collectionPersister.isManyToMany() ) {
		SQLLoadable persister = ( SQLLoadable ) collectionPersister.getElementPersister();
		addPersister( alias, filter( propertyResults ), persister );
	}
}
 
Example 4
private void addCollection(String role, String alias, Map propertyResults) {
	SQLLoadableCollection collectionPersister = ( SQLLoadableCollection ) factory.getCollectionPersister( role );
	alias2CollectionPersister.put( alias, collectionPersister );
	String suffix = generateCollectionSuffix();
	log.trace( "mapping alias [" + alias + "] to collection-suffix [" + suffix + "]" );
	alias2CollectionSuffix.put( alias, suffix );
	collectionPropertyResultMaps.put( alias, propertyResults );

	if ( collectionPersister.isOneToMany() ) {
		SQLLoadable persister = ( SQLLoadable ) collectionPersister.getElementPersister();
		addPersister( alias, filter( propertyResults ), persister );
	}
}
 
Example 5
Source Project: lams   Source File: SQLCustomQuery.java    License: GNU General Public License v2.0 4 votes vote down vote up
public SQLLoadableCollection getCollectionPersisterByAlias(String alias) {
	return aliasContext.getCollectionPersister( alias );
}
 
Example 6
Source Project: lams   Source File: SQLQueryReturnProcessor.java    License: GNU General Public License v2.0 4 votes vote down vote up
public SQLLoadableCollection getCollectionPersister(String alias) {
	return (SQLLoadableCollection) alias2CollectionPersister.get( alias );
}
 
Example 7
Source Project: lams   Source File: SQLQueryParser.java    License: GNU General Public License v2.0 4 votes vote down vote up
private String resolveCollectionProperties(
		String aliasName,
		String propertyName) {

	Map fieldResults = context.getPropertyResultsMapByAlias( aliasName );
	SQLLoadableCollection collectionPersister = context.getCollectionPersisterByAlias( aliasName );
	String collectionSuffix = context.getCollectionSuffixByAlias( aliasName );

	if ( "*".equals( propertyName ) ) {
		if( !fieldResults.isEmpty() ) {
			throw new QueryException("Using return-propertys together with * syntax is not supported.");
		}
		
		String selectFragment = collectionPersister.selectFragment( aliasName, collectionSuffix );
		aliasesFound++;
		return selectFragment 
					+ ", " 
					+ resolveProperties( aliasName, propertyName );
	}
	else if ( "element.*".equals( propertyName ) ) {
		return resolveProperties( aliasName, "*" );
	}
	else {
		String[] columnAliases;

		// Let return-propertys override whatever the persister has for aliases.
		columnAliases = ( String[] ) fieldResults.get(propertyName);
		if ( columnAliases==null ) {
			columnAliases = collectionPersister.getCollectionPropertyColumnAliases( propertyName, collectionSuffix );
		}
		
		if ( columnAliases == null || columnAliases.length == 0 ) {
			throw new QueryException(
					"No column name found for property [" + propertyName + "] for alias [" + aliasName + "]",
					originalQueryString
			);
		}
		if ( columnAliases.length != 1 ) {
			// TODO: better error message since we actually support composites if names are explicitly listed.
			throw new QueryException(
					"SQL queries only support properties mapped to a single column - property [" +
					propertyName + "] is mapped to " + columnAliases.length + " columns.",
					originalQueryString
			);
		}
		aliasesFound++;
		return columnAliases[0];
	
	}
}
 
Example 8
private String resolveCollectionProperties(
		String aliasName,
		String propertyName) {

	Map fieldResults = context.getPropertyResultsMapByAlias( aliasName );
	SQLLoadableCollection collectionPersister = context.getCollectionPersisterByAlias( aliasName );
	String collectionSuffix = context.getCollectionSuffixByAlias( aliasName );

	if ( "*".equals( propertyName ) ) {
		if ( !fieldResults.isEmpty() ) {
			throw new QueryException( "Using return-propertys together with * syntax is not supported." );
		}

		String selectFragment = collectionPersister.selectFragment( aliasName, collectionSuffix );
		aliasesFound++;
		return selectFragment
				+ ", "
				+ resolveProperties( aliasName, propertyName );
	}
	else if ( "element.*".equals( propertyName ) ) {
		return resolveProperties( aliasName, "*" );
	}
	else {
		String[] columnAliases;

		// Let return-propertys override whatever the persister has for aliases.
		columnAliases = (String[]) fieldResults.get( propertyName );
		if ( columnAliases == null ) {
			columnAliases = collectionPersister.getCollectionPropertyColumnAliases( propertyName, collectionSuffix );
		}

		if ( columnAliases == null || columnAliases.length == 0 ) {
			throw new QueryException(
					"No column name found for property [" + propertyName + "] for alias [" + aliasName + "]",
					originalQuery );
		}
		if ( columnAliases.length != 1 ) {
			// TODO: better error message since we actually support composites if names are explicitly listed.
			throw new QueryException(
					"SQL queries only support properties mapped to a single column - property [" +
							propertyName + "] is mapped to " + columnAliases.length + " columns.",
					originalQuery );
		}
		aliasesFound++;
		return columnAliases[0];

	}
}
 
Example 9
@Override
public SQLLoadableCollection getCollectionPersisterByAlias(String alias) {
	return null;
}
 
Example 10
public SQLLoadableCollection getCollectionPersisterByAlias(String alias) {
	return aliasContext.getCollectionPersister( alias );
}
 
Example 11
public SQLLoadableCollection getCollectionPersister(String alias) {
	return ( SQLLoadableCollection ) alias2CollectionPersister.get( alias );
}
 
Example 12
private String resolveCollectionProperties(
		String aliasName,
		String propertyName) {

	Map fieldResults = context.getPropertyResultsMapByAlias( aliasName );
	SQLLoadableCollection collectionPersister = context.getCollectionPersisterByAlias( aliasName );
	String collectionSuffix = context.getCollectionSuffixByAlias( aliasName );

	if ( "*".equals( propertyName ) ) {
		if( !fieldResults.isEmpty() ) {
			throw new QueryException("Using return-propertys together with * syntax is not supported.");
		}
		
		String selectFragment = collectionPersister.selectFragment( aliasName, collectionSuffix );
		aliasesFound++;
		return selectFragment 
					+ ", " 
					+ resolveProperties( aliasName, propertyName );
	}
	else if ( "element.*".equals( propertyName ) ) {
		return resolveProperties( aliasName, "*" );
	}
	else {
		String[] columnAliases;

		// Let return-propertys override whatever the persister has for aliases.
		columnAliases = ( String[] ) fieldResults.get(propertyName);
		if ( columnAliases==null ) {
			columnAliases = collectionPersister.getCollectionPropertyColumnAliases( propertyName, collectionSuffix );
		}
		
		if ( columnAliases == null || columnAliases.length == 0 ) {
			throw new QueryException(
					"No column name found for property [" + propertyName + "] for alias [" + aliasName + "]",
					originalQueryString
			);
		}
		if ( columnAliases.length != 1 ) {
			// TODO: better error message since we actually support composites if names are explicitly listed.
			throw new QueryException(
					"SQL queries only support properties mapped to a single column - property [" +
					propertyName + "] is mapped to " + columnAliases.length + " columns.",
					originalQueryString
			);
		}
		aliasesFound++;
		return columnAliases[0];
	
	}
}
 
Example 13
Source Project: lams   Source File: SQLQueryParser.java    License: GNU General Public License v2.0 votes vote down vote up
SQLLoadableCollection getCollectionPersisterByAlias(String alias); 
Example 14
SQLLoadableCollection getCollectionPersisterByAlias(String alias); 
Example 15
SQLLoadableCollection getCollectionPersisterByAlias(String alias);