org.hibernate.persister.collection.SQLLoadableCollection Java Examples

The following examples show how to use org.hibernate.persister.collection.SQLLoadableCollection. 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: ColumnCollectionAliases.java    From lams with 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
Source File: ColumnCollectionAliases.java    From cacheonix-core with GNU Lesser General Public License v2.1 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 #3
Source File: SQLQueryReturnProcessor.java    From lams with 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
Source File: SQLQueryReturnProcessor.java    From cacheonix-core with GNU Lesser General Public License v2.1 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.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 File: SQLCustomQuery.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
public SQLLoadableCollection getCollectionPersisterByAlias(String alias) {
	return aliasContext.getCollectionPersister( alias );
}
 
Example #6
Source File: SQLQueryReturnProcessor.java    From lams with 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 File: SQLQueryParser.java    From lams with 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
Source File: IgniteSqlQueryParser.java    From hibernate-ogm-ignite with GNU Lesser General Public License v2.1 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 + "]",
					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
Source File: IgniteSqlQueryParser.java    From hibernate-ogm-ignite with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public SQLLoadableCollection getCollectionPersisterByAlias(String alias) {
	return null;
}
 
Example #10
Source File: SQLCustomQuery.java    From cacheonix-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public SQLLoadableCollection getCollectionPersisterByAlias(String alias) {
	return aliasContext.getCollectionPersister( alias );
}
 
Example #11
Source File: SQLQueryReturnProcessor.java    From cacheonix-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public SQLLoadableCollection getCollectionPersister(String alias) {
	return ( SQLLoadableCollection ) alias2CollectionPersister.get( alias );
}
 
Example #12
Source File: SQLQueryParser.java    From cacheonix-core with GNU Lesser General Public License v2.1 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 #13
Source File: SQLQueryParser.java    From lams with GNU General Public License v2.0 votes vote down vote up
SQLLoadableCollection getCollectionPersisterByAlias(String alias); 
Example #14
Source File: IgniteSqlQueryParser.java    From hibernate-ogm-ignite with GNU Lesser General Public License v2.1 votes vote down vote up
SQLLoadableCollection getCollectionPersisterByAlias(String alias); 
Example #15
Source File: SQLQueryParser.java    From cacheonix-core with GNU Lesser General Public License v2.1 votes vote down vote up
SQLLoadableCollection getCollectionPersisterByAlias(String alias);