Java Code Examples for org.hibernate.cfg.Environment#useReflectionOptimizer()

The following examples show how to use org.hibernate.cfg.Environment#useReflectionOptimizer() . 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: PojoEntityTuplizer.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public PojoEntityTuplizer(EntityMetamodel entityMetamodel, PersistentClass mappedEntity) {
		super( entityMetamodel, mappedEntity );
		this.mappedClass = mappedEntity.getMappedClass();
		this.proxyInterface = mappedEntity.getProxyInterface();
		this.lifecycleImplementor = Lifecycle.class.isAssignableFrom( mappedClass );
		this.isBytecodeEnhanced = entityMetamodel.getBytecodeEnhancementMetadata().isEnhancedForLazyLoading();

		String[] getterNames = new String[propertySpan];
		String[] setterNames = new String[propertySpan];
		Class[] propTypes = new Class[propertySpan];
		for ( int i = 0; i < propertySpan; i++ ) {
			getterNames[i] = getters[i].getMethodName();
			setterNames[i] = setters[i].getMethodName();
			propTypes[i] = getters[i].getReturnType();
		}

		if ( hasCustomAccessors || !Environment.useReflectionOptimizer() ) {
			optimizer = null;
		}
		else {
			// todo : YUCK!!!
			optimizer = Environment.getBytecodeProvider().getReflectionOptimizer(
					mappedClass,
					getterNames,
					setterNames,
					propTypes
			);
//			optimizer = getFactory().getSettings().getBytecodeProvider().getReflectionOptimizer(
//					mappedClass, getterNames, setterNames, propTypes
//			);
		}
	}
 
Example 2
Source File: PojoComponentTuplizer.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public PojoComponentTuplizer(Component component) {
	super( component );

	String[] getterNames = new String[propertySpan];
	String[] setterNames = new String[propertySpan];
	Class[] propTypes = new Class[propertySpan];
	for ( int i = 0; i < propertySpan; i++ ) {
		getterNames[i] = getters[i].getMethodName();
		setterNames[i] = setters[i].getMethodName();
		propTypes[i] = getters[i].getReturnType();
	}

	final String parentPropertyName = component.getParentProperty();
	if ( parentPropertyName == null ) {
		parentSetter = null;
		parentGetter = null;
	}
	else {
		final PropertyAccess propertyAccess = PropertyAccessStrategyBasicImpl.INSTANCE.buildPropertyAccess(
				componentClass,
				parentPropertyName
		);
		parentSetter = propertyAccess.getSetter();
		parentGetter = propertyAccess.getGetter();
	}

	if ( hasCustomAccessors || !Environment.useReflectionOptimizer() ) {
		optimizer = null;
	}
	else {
		// TODO: here is why we need to make bytecode provider global :(
		// TODO : again, fix this after HHH-1907 is complete
		optimizer = Environment.getBytecodeProvider().getReflectionOptimizer(
				componentClass, getterNames, setterNames, propTypes
		);
	}
}
 
Example 3
Source File: PojoEntityTuplizer.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public PojoEntityTuplizer(EntityMetamodel entityMetamodel, PersistentClass mappedEntity) {
		super( entityMetamodel, mappedEntity );
		this.mappedClass = mappedEntity.getMappedClass();
		this.proxyInterface = mappedEntity.getProxyInterface();
		this.lifecycleImplementor = Lifecycle.class.isAssignableFrom( mappedClass );
		this.validatableImplementor = Validatable.class.isAssignableFrom( mappedClass );

		Iterator iter = mappedEntity.getPropertyClosureIterator();
		while ( iter.hasNext() ) {
			Property property = (Property) iter.next();
			if ( property.isLazy() ) {
				lazyPropertyNames.add( property.getName() );
			}
		}

		String[] getterNames = new String[propertySpan];
		String[] setterNames = new String[propertySpan];
		Class[] propTypes = new Class[propertySpan];
		for ( int i = 0; i < propertySpan; i++ ) {
			getterNames[i] = getters[i].getMethodName();
			setterNames[i] = setters[i].getMethodName();
			propTypes[i] = getters[i].getReturnType();
		}

		if ( hasCustomAccessors || !Environment.useReflectionOptimizer() ) {
			optimizer = null;
		}
		else {
			// todo : YUCK!!!
			optimizer = Environment.getBytecodeProvider().getReflectionOptimizer( mappedClass, getterNames, setterNames, propTypes );
//			optimizer = getFactory().getSettings().getBytecodeProvider().getReflectionOptimizer(
//					mappedClass, getterNames, setterNames, propTypes
//			);
		}
	
	}
 
Example 4
Source File: PojoComponentTuplizer.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public PojoComponentTuplizer(Component component) {
	super( component );

	this.componentClass = component.getComponentClass();

	String[] getterNames = new String[propertySpan];
	String[] setterNames = new String[propertySpan];
	Class[] propTypes = new Class[propertySpan];
	for ( int i = 0; i < propertySpan; i++ ) {
		getterNames[i] = getters[i].getMethodName();
		setterNames[i] = setters[i].getMethodName();
		propTypes[i] = getters[i].getReturnType();
	}

	final String parentPropertyName = component.getParentProperty();
	if ( parentPropertyName == null ) {
		parentSetter = null;
		parentGetter = null;
	}
	else {
		PropertyAccessor pa = PropertyAccessorFactory.getPropertyAccessor( null );
		parentSetter = pa.getSetter( componentClass, parentPropertyName );
		parentGetter = pa.getGetter( componentClass, parentPropertyName );
	}

	if ( hasCustomAccessors || !Environment.useReflectionOptimizer() ) {
		optimizer = null;
	}
	else {
		// TODO: here is why we need to make bytecode provider global :(
		// TODO : again, fix this after HHH-1907 is complete
		optimizer = Environment.getBytecodeProvider().getReflectionOptimizer(
				componentClass, getterNames, setterNames, propTypes
		);
	}
}