Java Code Examples for org.hibernate.transform.Transformers#ALIAS_TO_ENTITY_MAP

The following examples show how to use org.hibernate.transform.Transformers#ALIAS_TO_ENTITY_MAP . 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: ConstructorNode.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public ResultTransformer getResultTransformer() {
	if ( constructor != null ) {
		return new AliasToBeanConstructorResultTransformer( constructor );
	}
	else if ( isMap ) {
		return Transformers.ALIAS_TO_ENTITY_MAP;
	}
	else if ( isList ) {
		return Transformers.TO_LIST;
	}
	throw new QueryException( "Unable to determine proper dynamic-instantiation tranformer to use." );
}
 
Example 2
Source File: HolderInstantiator.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public static ResultTransformer createSelectNewTransformer(Constructor constructor, boolean returnMaps, boolean returnLists) {
	if ( constructor != null ) {
		return new AliasToBeanConstructorResultTransformer(constructor);
	}
	else if ( returnMaps ) {
		return Transformers.ALIAS_TO_ENTITY_MAP;			
	}
	else if ( returnLists ) {
		return Transformers.TO_LIST;
	}		
	else {
		return null;
	}
}
 
Example 3
Source File: QueryBuilder.java    From spring-data-jpa-extra with Apache License 2.0 5 votes vote down vote up
public static <C> Query transform(Query query, Class<C> clazz) {
    ResultTransformer transformer;
    if (Map.class.isAssignableFrom(clazz)) {
        transformer = Transformers.ALIAS_TO_ENTITY_MAP;
    } else if (Number.class.isAssignableFrom(clazz) || clazz.isPrimitive() || String.class.isAssignableFrom(clazz) ||
            Date.class.isAssignableFrom(clazz)) {
        transformer = transformerCache.computeIfAbsent(clazz, SmartTransformer::new);
    } else {
        transformer = transformerCache.computeIfAbsent(clazz, BeanTransformerAdapter::new);
    }
    return query.setResultTransformer(transformer);
}
 
Example 4
Source File: HolderInstantiator.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static ResultTransformer createSelectNewTransformer(Constructor constructor, boolean returnMaps, boolean returnLists) {
	if ( constructor != null ) {
		return new AliasToBeanConstructorResultTransformer(constructor);
	}
	else if ( returnMaps ) {
		return Transformers.ALIAS_TO_ENTITY_MAP;			
	}
	else if ( returnLists ) {
		return Transformers.TO_LIST;
	}		
	else {
		return null;
	}
}