Java Code Examples for org.hibernate.internal.util.collections.ArrayHelper#toStringArray()

The following examples show how to use org.hibernate.internal.util.collections.ArrayHelper#toStringArray() . 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: CustomLoader.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void autoDiscoverTypes(ResultSet rs) {
	try {
		JdbcResultMetadata metadata = new JdbcResultMetadata( getFactory(), rs );
		rowProcessor.prepareForAutoDiscovery( metadata );

		List<String> aliases = new ArrayList<>();
		List<Type> types = new ArrayList<>();
		for ( ResultColumnProcessor resultProcessor : rowProcessor.getColumnProcessors() ) {
			resultProcessor.performDiscovery( metadata, types, aliases );
		}

		validateAliases( aliases );

		resultTypes = ArrayHelper.toTypeArray( types );
		transformerAliases = ArrayHelper.toStringArray( aliases );
	}
	catch (SQLException e) {
		throw new HibernateException( "Exception while trying to autodiscover types.", e );
	}
}
 
Example 2
Source File: CriteriaJoinWalker.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public CriteriaJoinWalker(
		final OuterJoinLoadable persister,
		final CriteriaQueryTranslator translator,
		final SessionFactoryImplementor factory,
		final CriteriaImpl criteria,
		final String rootEntityName,
		final LoadQueryInfluencers loadQueryInfluencers,
		final String alias) {
	super( persister, factory, loadQueryInfluencers, alias );

	this.translator = translator;

	querySpaces = translator.getQuerySpaces();

	if ( translator.hasProjection() ) {
		initProjection(
				translator.getSelect(),
				translator.getWhereCondition(),
				translator.getOrderBy(),
				translator.getGroupBy(),
				LockOptions.NONE
		);
		resultTypes = translator.getProjectedTypes();
		userAliases = translator.getProjectedAliases();
		includeInResultRow = new boolean[resultTypes.length];
		Arrays.fill( includeInResultRow, true );
	}
	else {
		initAll( translator.getWhereCondition(), translator.getOrderBy(), LockOptions.NONE );
		// root entity comes last
		userAliasList.add( criteria.getAlias() ); //root entity comes *last*
		resultTypeList.add( translator.getResultType( criteria ) );
		includeInResultRowList.add( true );
		userAliases = ArrayHelper.toStringArray( userAliasList );
		resultTypes = ArrayHelper.toTypeArray( resultTypeList );
		includeInResultRow = ArrayHelper.toBooleanArray( includeInResultRowList );
	}
}
 
Example 3
Source File: StatisticsImpl.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public String[] getEntityNames() {
	if ( sessionFactory == null ) {
		return ArrayHelper.toStringArray( entityStatsMap.keySet() );
	}
	else {
		return sessionFactory.getMetamodel().getAllEntityNames();
	}
}
 
Example 4
Source File: StatisticsImpl.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public String[] getCollectionRoleNames() {
	if ( sessionFactory == null ) {
		return ArrayHelper.toStringArray( collectionStatsMap.keySet() );
	}
	else {
		return sessionFactory.getMetamodel().getAllCollectionRoles();
	}
}
 
Example 5
Source File: MetamodelImpl.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public String[] getAllEntityNames() {
	return ArrayHelper.toStringArray( entityPersisterMap.keySet() );
}
 
Example 6
Source File: MetamodelImpl.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public String[] getAllCollectionRoles() {
	return ArrayHelper.toStringArray( collectionPersisterMap.keySet() );
}
 
Example 7
Source File: AbstractProducedQuery.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public String[] getNamedParameters() {
	return ArrayHelper.toStringArray( getParameterMetadata().getNamedParameterNames() );
}
 
Example 8
Source File: HQLQueryPlan.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
protected HQLQueryPlan(
		String hql,
		String collectionRole,
		boolean shallow,
		Map<String,Filter> enabledFilters,
		SessionFactoryImplementor factory,
		EntityGraphQueryHint entityGraphQueryHint) {
	this.sourceQuery = hql;
	this.shallow = shallow;
	this.factory = factory;

	final Set<String> copy = new HashSet<>();
	copy.addAll( enabledFilters.keySet() );
	this.enabledFilterNames = java.util.Collections.unmodifiableSet( copy );

	final String[] concreteQueryStrings = QuerySplitter.concreteQueries( hql, factory );
	final int length = concreteQueryStrings.length;
	this.translators = new QueryTranslator[length];

	final List<String> sqlStringList = new ArrayList<>();
	final Set<Serializable> combinedQuerySpaces = new HashSet<>();

	final Map querySubstitutions = factory.getSessionFactoryOptions().getQuerySubstitutions();
	final QueryTranslatorFactory queryTranslatorFactory = factory.getServiceRegistry().getService( QueryTranslatorFactory.class );


	for ( int i=0; i<length; i++ ) {
		if ( collectionRole == null ) {
			translators[i] = queryTranslatorFactory
					.createQueryTranslator( hql, concreteQueryStrings[i], enabledFilters, factory, entityGraphQueryHint );
			translators[i].compile( querySubstitutions, shallow );
		}
		else {
			translators[i] = queryTranslatorFactory
					.createFilterTranslator( hql, concreteQueryStrings[i], enabledFilters, factory );
			( (FilterTranslator) translators[i] ).compile( collectionRole, querySubstitutions, shallow );
		}
		combinedQuerySpaces.addAll( translators[i].getQuerySpaces() );
		sqlStringList.addAll( translators[i].collectSqlStrings() );
	}

	this.sqlStrings = ArrayHelper.toStringArray( sqlStringList );
	this.querySpaces = combinedQuerySpaces;

	if ( length == 0 ) {
		parameterMetadata = new ParameterMetadataImpl( null, null );
		returnMetadata = null;
	}
	else {
		this.parameterMetadata = buildParameterMetadata( translators[0].getParameterTranslations(), hql );
		if ( translators[0].isManipulationStatement() ) {
			returnMetadata = null;
		}
		else {
			final Type[] types = ( length > 1 ) ? new Type[translators[0].getReturnTypes().length] : translators[0].getReturnTypes();
			returnMetadata = new ReturnMetadata( translators[0].getReturnAliases(), types );
		}
	}
}
 
Example 9
Source File: StatisticsImpl.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public String[] getQueries() {
	return ArrayHelper.toStringArray( queryStatsMap.keySet() );
}
 
Example 10
Source File: EnabledCaching.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public String[] getSecondLevelCacheRegionNames() {
	return ArrayHelper.toStringArray( legacySecondLevelCacheNames );
}