Java Code Examples for org.hibernate.mapping.Component#getComponentClass()

The following examples show how to use org.hibernate.mapping.Component#getComponentClass() . 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: PojoInstantiator.java    From cacheonix-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
public PojoInstantiator(Component component, ReflectionOptimizer.InstantiationOptimizer optimizer) {
	this.mappedClass = component.getComponentClass();
	this.optimizer = optimizer;

	this.proxyInterface = null;
	this.embeddedIdentifier = false;

	try {
		constructor = ReflectHelper.getDefaultConstructor(mappedClass);
	}
	catch ( PropertyNotFoundException pnfe ) {
		log.info(
		        "no default (no-argument) constructor for class: " +
				mappedClass.getName() +
				" (class must be instantiated by Interceptor)"
		);
		constructor = null;
	}
}
 
Example 2
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
		);
	}
}
 
Example 3
Source File: PojoComponentTuplizer.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public ProxiedInstantiator(Component component) {
	proxiedClass = component.getComponentClass();
	if ( proxiedClass.isInterface() ) {
		factory = Environment.getBytecodeProvider()
				.getProxyFactoryFactory()
				.buildBasicProxyFactory( null, new Class[] { proxiedClass } );
	}
	else {
		factory = Environment.getBytecodeProvider()
				.getProxyFactoryFactory()
				.buildBasicProxyFactory( proxiedClass, null );
	}
}
 
Example 4
Source File: AttributeFactory.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
private <Y> Type<Y> getMetaModelType(ValueContext typeContext) {
	switch ( typeContext.getValueClassification() ) {
		case BASIC: {
			return new BasicTypeImpl<Y>(
					typeContext.getBindableType(),
					Type.PersistenceType.BASIC
			);
		}
		case ENTITY: {
			final org.hibernate.type.EntityType type = (EntityType) typeContext.getValue().getType();
			return (Type<Y>) context.locateEntityType( type.getAssociatedEntityName() );
		}
		case EMBEDDABLE: {
			final Component component = (Component) typeContext.getValue();
			Class javaType;
			if ( component.getComponentClassName() == null ) {
				javaType = typeContext.getBindableType();
			}
			else {
				javaType = component.getComponentClass();
			}
			final EmbeddableTypeImpl<Y> embeddableType = new EmbeddableTypeImpl<Y>(
					javaType,
					typeContext.getAttributeMetadata().getOwnerType(),
					(ComponentType) typeContext.getValue().getType()
			);
			context.registerEmbeddedableType( embeddableType );
			final Iterator<Property> subProperties = component.getPropertyIterator();
			while ( subProperties.hasNext() ) {
				final Property property = subProperties.next();
				final AttributeImplementor<Y, Object> attribute = buildAttribute( embeddableType, property );
				if ( attribute != null ) {
					embeddableType.getBuilder().addAttribute( attribute );
				}
			}
			embeddableType.lock();
			return embeddableType;
		}
		default: {
			throw new AssertionFailure( "Unknown type : " + typeContext.getValueClassification() );
		}
	}
}
 
Example 5
Source File: PojoInstantiator.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
public PojoInstantiator(Component component, ReflectionOptimizer.InstantiationOptimizer optimizer) {
	this( component.getComponentClass(), optimizer );
}
 
Example 6
Source File: PojoComponentTuplizer.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected void setComponentClass(Component component) {
	this.componentClass = component.getComponentClass();
}