类org.hibernate.persister.entity.SQLLoadable源码实例Demo

下面列出了怎么用org.hibernate.persister.entity.SQLLoadable的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: lams   文件: SQLQueryReturnProcessor.java
private SQLLoadable getSQLLoadable(String entityName) throws MappingException {
	EntityPersister persister = factory.getEntityPersister( entityName );
	if ( !(persister instanceof SQLLoadable) ) {
		throw new MappingException( "class persister is not SQLLoadable: " + entityName );
	}
	return (SQLLoadable) persister;
}
 
源代码2 项目: lams   文件: SQLQueryReturnProcessor.java
private void processRootReturn(NativeSQLQueryRootReturn rootReturn) {
	if ( alias2Persister.containsKey( rootReturn.getAlias() ) ) {
		// already been processed...
		return;
	}

	SQLLoadable persister = getSQLLoadable( rootReturn.getReturnEntityName() );
	addPersister( rootReturn.getAlias(), rootReturn.getPropertyResultsMap(), persister );
}
 
源代码3 项目: lams   文件: SQLQueryReturnProcessor.java
private void addPersister(String alias, Map propertyResult, SQLLoadable persister) {
	alias2Persister.put( alias, persister );
	String suffix = generateEntitySuffix();
	LOG.tracev( "Mapping alias [{0}] to entity-suffix [{1}]", alias, suffix );
	alias2Suffix.put( alias, suffix );
	entityPropertyResultMaps.put( alias, propertyResult );
}
 
源代码4 项目: lams   文件: SQLQueryReturnProcessor.java
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 );
	}
}
 
源代码5 项目: lams   文件: SQLQueryReturnProcessor.java
private void processJoinReturn(NativeSQLQueryJoinReturn fetchReturn) {
		String alias = fetchReturn.getAlias();
//		if ( alias2Persister.containsKey( alias ) || collectionAliases.contains( alias ) ) {
		if ( alias2Persister.containsKey( alias ) || alias2CollectionPersister.containsKey( alias ) ) {
			// already been processed...
			return;
		}

		String ownerAlias = fetchReturn.getOwnerAlias();

		// Make sure the owner alias is known...
		if ( !alias2Return.containsKey( ownerAlias ) ) {
			throw new HibernateException( "Owner alias [" + ownerAlias + "] is unknown for alias [" + alias + "]" );
		}

		// If this return's alias has not been processed yet, do so b4 further processing of this return
		if ( !alias2Persister.containsKey( ownerAlias ) ) {
			NativeSQLQueryNonScalarReturn ownerReturn = ( NativeSQLQueryNonScalarReturn ) alias2Return.get(ownerAlias);
			processReturn( ownerReturn );
		}

		SQLLoadable ownerPersister = ( SQLLoadable ) alias2Persister.get( ownerAlias );
		Type returnType = ownerPersister.getPropertyType( fetchReturn.getOwnerProperty() );

		if ( returnType.isCollectionType() ) {
			String role = ownerPersister.getEntityName() + '.' + fetchReturn.getOwnerProperty();
			addCollection( role, alias, fetchReturn.getPropertyResultsMap() );
//			collectionOwnerAliases.add( ownerAlias );
		}
		else if ( returnType.isEntityType() ) {
			EntityType eType = ( EntityType ) returnType;
			String returnEntityName = eType.getAssociatedEntityName();
			SQLLoadable persister = getSQLLoadable( returnEntityName );
			addPersister( alias, fetchReturn.getPropertyResultsMap(), persister );
		}

	}
 
源代码6 项目: lams   文件: SQLQueryParser.java
private String resolveProperties(String aliasName, String propertyName) {
	Map fieldResults = context.getPropertyResultsMapByAlias( aliasName );
	SQLLoadable persister = context.getEntityPersisterByAlias( aliasName );
	String suffix = context.getEntitySuffixByAlias( aliasName );

	if ( "*".equals( propertyName ) ) {
		if( !fieldResults.isEmpty() ) {
			throw new QueryException("Using return-propertys together with * syntax is not supported.");
		}			
		aliasesFound++;
		return persister.selectFragment( aliasName, suffix ) ;
	}
	else {

		String[] columnAliases;

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

		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];
	}
}
 
private String resolveProperties(
		String aliasName,
		String propertyName) {
	Map fieldResults = context.getPropertyResultsMapByAlias( aliasName );
	SQLLoadable persister = context.getEntityPersisterByAlias( aliasName );
	String suffix = context.getEntitySuffixByAlias( aliasName );

	if ( "*".equals( propertyName ) ) {
		if ( !fieldResults.isEmpty() ) {
			throw new QueryException( "Using return-propertys together with * syntax is not supported." );
		}
		aliasesFound++;
		return persister.selectFragment( aliasName, suffix );
	}
	else {

		String[] columnAliases;

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

		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];
	}
}
 
源代码8 项目: cacheonix-core   文件: SQLQueryReturnProcessor.java
private SQLLoadable getSQLLoadable(String entityName) throws MappingException {
	EntityPersister persister = factory.getEntityPersister( entityName );
	if ( !(persister instanceof SQLLoadable) ) {
		throw new MappingException( "class persister is not SQLLoadable: " + entityName );
	}
	return (SQLLoadable) persister;
}
 
源代码9 项目: cacheonix-core   文件: SQLQueryReturnProcessor.java
private void processRootReturn(NativeSQLQueryRootReturn rootReturn) {
	if ( alias2Persister.containsKey( rootReturn.getAlias() ) ) {
		// already been processed...
		return;
	}

	SQLLoadable persister = getSQLLoadable( rootReturn.getReturnEntityName() );
	addPersister( rootReturn.getAlias(), rootReturn.getPropertyResultsMap(), persister );
}
 
源代码10 项目: cacheonix-core   文件: SQLQueryReturnProcessor.java
/**
 * @param propertyResult
 * @param persister
 */
private void addPersister(String alias, Map propertyResult, SQLLoadable persister) {
	alias2Persister.put( alias, persister );
	String suffix = generateEntitySuffix();
	log.trace( "mapping alias [" + alias + "] to entity-suffix [" + suffix + "]" );
	alias2Suffix.put( alias, suffix );
	entityPropertyResultMaps.put( alias, propertyResult );
}
 
源代码11 项目: cacheonix-core   文件: SQLQueryReturnProcessor.java
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 );
	}
}
 
源代码12 项目: cacheonix-core   文件: SQLQueryReturnProcessor.java
private void processJoinReturn(NativeSQLQueryJoinReturn fetchReturn) {
		String alias = fetchReturn.getAlias();
//		if ( alias2Persister.containsKey( alias ) || collectionAliases.contains( alias ) ) {
		if ( alias2Persister.containsKey( alias ) || alias2CollectionPersister.containsKey( alias ) ) {
			// already been processed...
			return;
		}

		String ownerAlias = fetchReturn.getOwnerAlias();

		// Make sure the owner alias is known...
		if ( !alias2Return.containsKey( ownerAlias ) ) {
			throw new HibernateException( "Owner alias [" + ownerAlias + "] is unknown for alias [" + alias + "]" );
		}

		// If this return's alias has not been processed yet, do so b4 further processing of this return
		if ( !alias2Persister.containsKey( ownerAlias ) ) {
			NativeSQLQueryNonScalarReturn ownerReturn = ( NativeSQLQueryNonScalarReturn ) alias2Return.get(ownerAlias);
			processReturn( ownerReturn );
		}

		SQLLoadable ownerPersister = ( SQLLoadable ) alias2Persister.get( ownerAlias );
		Type returnType = ownerPersister.getPropertyType( fetchReturn.getOwnerProperty() );

		if ( returnType.isCollectionType() ) {
			String role = ownerPersister.getEntityName() + '.' + fetchReturn.getOwnerProperty();
			addCollection( role, alias, fetchReturn.getPropertyResultsMap() );
//			collectionOwnerAliases.add( ownerAlias );
		}
		else if ( returnType.isEntityType() ) {
			EntityType eType = ( EntityType ) returnType;
			String returnEntityName = eType.getAssociatedEntityName();
			SQLLoadable persister = getSQLLoadable( returnEntityName );
			addPersister( alias, fetchReturn.getPropertyResultsMap(), persister );
		}

	}
 
源代码13 项目: lams   文件: SQLCustomQuery.java
public SQLLoadable getEntityPersisterByAlias(String alias) {
	return aliasContext.getEntityPersister( alias );
}
 
源代码14 项目: lams   文件: SQLQueryReturnProcessor.java
public SQLLoadable getEntityPersister(String alias) {
	return (SQLLoadable) alias2Persister.get( alias );
}
 
@Override
public SQLLoadable getEntityPersisterByAlias(String alias) {
	return null;
}
 
源代码16 项目: cacheonix-core   文件: SQLCustomQuery.java
public SQLLoadable getEntityPersisterByAlias(String alias) {
	return aliasContext.getEntityPersister( alias );
}
 
源代码17 项目: cacheonix-core   文件: SQLQueryReturnProcessor.java
public SQLLoadable getEntityPersister(String alias) {
	return ( SQLLoadable ) alias2Persister.get( alias );
}
 
源代码18 项目: cacheonix-core   文件: SQLQueryParser.java
private String resolveProperties(
		String aliasName,
        String propertyName) {
	Map fieldResults = context.getPropertyResultsMapByAlias( aliasName );
	SQLLoadable persister = context.getEntityPersisterByAlias( aliasName );
	String suffix = context.getEntitySuffixByAlias( aliasName );

	if ( "*".equals( propertyName ) ) {
		if( !fieldResults.isEmpty() ) {
			throw new QueryException("Using return-propertys together with * syntax is not supported.");
		}			
		aliasesFound++;
		return persister.selectFragment( aliasName, suffix ) ;
	}
	else {

		String[] columnAliases;

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

		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];
	}
}
 
源代码19 项目: lams   文件: SQLQueryParser.java
SQLLoadable getEntityPersisterByAlias(String alias); 
SQLLoadable getEntityPersisterByAlias(String alias); 
源代码21 项目: cacheonix-core   文件: SQLQueryParser.java
SQLLoadable getEntityPersisterByAlias(String alias); 
 类所在包
 类方法
 同包方法