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

The following examples show how to use org.hibernate.util.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 cacheonix-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
protected void autoDiscoverTypes(ResultSet rs) {
	try {
		Metadata metadata = new Metadata( getFactory(), rs );
		List aliases = new ArrayList();
		List types = new ArrayList();

		rowProcessor.prepareForAutoDiscovery( metadata );

		for ( int i = 0; i < rowProcessor.columnProcessors.length; i++ ) {
			rowProcessor.columnProcessors[i].performDiscovery( metadata, types, 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: ProjectionList.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public String[] getColumnAliases(int loc) {
	List result = new ArrayList( getLength() );
	for ( int i=0; i<getLength(); i++ ) {
		String[] colAliases = getProjection(i).getColumnAliases(loc);
		ArrayHelper.addAll(result, colAliases);
		loc+=colAliases.length;
	}
	return ArrayHelper.toStringArray(result);
}
 
Example 3
Source File: ProjectionList.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public String[] getAliases() {
	List result = new ArrayList( getLength() );
	for ( int i=0; i<getLength(); i++ ) {
		String[] aliases = getProjection(i).getAliases();
		ArrayHelper.addAll(result, aliases);
	}
	return ArrayHelper.toStringArray(result);

}
 
Example 4
Source File: CriteriaJoinWalker.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public CriteriaJoinWalker(
		final OuterJoinLoadable persister, 
		final CriteriaQueryTranslator translator,
		final SessionFactoryImplementor factory, 
		final CriteriaImpl criteria, 
		final String rootEntityName,
		final Map enabledFilters)
throws HibernateException {
	super(persister, factory, enabledFilters);

	this.translator = translator;

	querySpaces = translator.getQuerySpaces();

	if ( translator.hasProjection() ) {
		resultTypes = translator.getProjectedTypes();
		
		initProjection( 
				translator.getSelect(), 
				translator.getWhereCondition(), 
				translator.getOrderBy(),
				translator.getGroupBy(),
				LockMode.NONE 
			);
	}
	else {
		resultTypes = new Type[] { TypeFactory.manyToOne( persister.getEntityName() ) };

		initAll( translator.getWhereCondition(), translator.getOrderBy(), LockMode.NONE );
	}
	
	userAliasList.add( criteria.getAlias() ); //root entity comes *last*
	userAliases = ArrayHelper.toStringArray(userAliasList);

}
 
Example 5
Source File: StatisticsImpl.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Get the names of all entities
 */
public String[] getEntityNames() {
	if (sessionFactory==null) {
		return ArrayHelper.toStringArray( entityStatistics.keySet() );
	}
	else {
		return ArrayHelper.toStringArray( sessionFactory.getAllClassMetadata().keySet() );
	}
}
 
Example 6
Source File: StatisticsImpl.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Get the names of all collection roles
 */
public String[] getCollectionRoleNames() {
	if (sessionFactory==null) {
		return ArrayHelper.toStringArray( collectionStatistics.keySet() );
	}
	else {
		return ArrayHelper.toStringArray( sessionFactory.getAllCollectionMetadata().keySet() );
	}
}
 
Example 7
Source File: StatisticsImpl.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Get all second-level cache region names
 */
public String[] getSecondLevelCacheRegionNames() {
	if (sessionFactory==null) {
		return ArrayHelper.toStringArray( secondLevelCacheStatistics.keySet() );
	}
	else {
		return ArrayHelper.toStringArray( sessionFactory.getAllSecondLevelCacheRegions().keySet() );
	}
}
 
Example 8
Source File: HQLQueryPlan.java    From cacheonix-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
protected HQLQueryPlan(String hql, String collectionRole, boolean shallow, Map enabledFilters, SessionFactoryImplementor factory) {
	this.sourceQuery = hql;
	this.shallow = shallow;

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

	Set combinedQuerySpaces = new HashSet();
	String[] concreteQueryStrings = QuerySplitter.concreteQueries( hql, factory );
	final int length = concreteQueryStrings.length;
	translators = new QueryTranslator[length];
	List sqlStringList = new ArrayList();
	for ( int i=0; i<length; i++ ) {
		if ( collectionRole == null ) {
			translators[i] = factory.getSettings()
					.getQueryTranslatorFactory()
					.createQueryTranslator( hql, concreteQueryStrings[i], enabledFilters, factory );
			translators[i].compile( factory.getSettings().getQuerySubstitutions(), shallow );
		}
		else {
			translators[i] = factory.getSettings()
					.getQueryTranslatorFactory()
					.createFilterTranslator( hql, concreteQueryStrings[i], enabledFilters, factory );
			( ( FilterTranslator ) translators[i] ).compile( collectionRole, factory.getSettings().getQuerySubstitutions(), shallow );
		}
		combinedQuerySpaces.addAll( translators[i].getQuerySpaces() );
		sqlStringList.addAll( translators[i].collectSqlStrings() );
	}

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

	if ( length == 0 ) {
		parameterMetadata = new ParameterMetadata( null, null );
		returnMetadata = null;
	}
	else {
		this.parameterMetadata = buildParameterMetadata( translators[0].getParameterTranslations(), hql );
		if ( translators[0].isManipulationStatement() ) {
			returnMetadata = null;
		}
		else {
			if ( length > 1 ) {
				final int returns = translators[0].getReturnTypes().length;
				returnMetadata = new ReturnMetadata( translators[0].getReturnAliases(), new Type[returns] );
			}
			else {
				returnMetadata = new ReturnMetadata( translators[0].getReturnAliases(), translators[0].getReturnTypes() );
			}
		}
	}
}
 
Example 9
Source File: StatisticsImpl.java    From cacheonix-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * Get all executed query strings
 */
public String[] getQueries() {
	return ArrayHelper.toStringArray( queryStatistics.keySet() );
}
 
Example 10
Source File: AbstractQueryImpl.java    From cacheonix-core with GNU Lesser General Public License v2.1 2 votes vote down vote up
/**
 * Returns an array representing all named parameter names encountered
 * during (intial) parsing of the query.
 * <p/>
 * Note <i>initial</i> here means different things depending on whether
 * this is a native-sql query or an HQL/filter query.  For native-sql, a
 * precursory inspection of the query string is performed specifically to
 * locate defined parameters.  For HQL/filter queries, this is the
 * information returned from the query-translator.  This distinction
 * holds true for all parameter metadata exposed here.
 *
 * @return Array of named parameter names.
 * @throws HibernateException
 */
public String[] getNamedParameters() throws HibernateException {
	return ArrayHelper.toStringArray( parameterMetadata.getNamedParameterNames() );
}