Java Code Examples for org.hibernate.mapping.Component

The following examples show how to use org.hibernate.mapping.Component. These examples are extracted from open source projects. 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 Project: teiid-spring-boot   Source File: ViewBuilder.java    License: Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
String propertyName(Iterator<org.hibernate.mapping.Property> it, org.hibernate.mapping.Property identifierProperty,
        String colName) {
    if (identifierProperty != null && propertyMatches(identifierProperty, colName)) {
        return identifierProperty.getName();
    }
    while (it.hasNext()) {
        org.hibernate.mapping.Property property = it.next();
        if (propertyMatches(property, colName)) {
            if (property.isComposite()) {
                Component comp = (Component) property.getValue();
                Iterator<org.hibernate.mapping.Property> compIt = comp.getPropertyIterator();
                return propertyName(compIt, null, colName);
            } else {
                return property.getName();
            }
        }
    }
    return null;
}
 
Example 2
Source Project: lams   Source File: ClassPropertyHolder.java    License: GNU General Public License v2.0 6 votes vote down vote up
public void addProperty(Property prop, XClass declaringClass) {
	if ( prop.getValue() instanceof Component ) {
		//TODO handle quote and non quote table comparison
		String tableName = prop.getValue().getTable().getName();
		if ( getJoinsPerRealTableName().containsKey( tableName ) ) {
			final Join join = getJoinsPerRealTableName().get( tableName );
			addPropertyToJoin( prop, declaringClass, join );
		}
		else {
			addPropertyToPersistentClass( prop, declaringClass );
		}
	}
	else {
		addPropertyToPersistentClass( prop, declaringClass );
	}
}
 
Example 3
Source Project: lams   Source File: AnnotationBinder.java    License: GNU General Public License v2.0 6 votes vote down vote up
public static Component fillComponent(
		PropertyHolder propertyHolder,
		PropertyData inferredData,
		AccessType propertyAccessor,
		boolean isNullable,
		EntityBinder entityBinder,
		boolean isComponentEmbedded,
		boolean isIdentifierMapper,
		boolean inSecondPass,
		MetadataBuildingContext buildingContext,
		Map<XClass, InheritanceState> inheritanceStatePerClass) {
	return fillComponent(
			propertyHolder,
			inferredData,
			null,
			propertyAccessor,
			isNullable,
			entityBinder,
			isComponentEmbedded,
			isIdentifierMapper,
			inSecondPass,
			buildingContext,
			inheritanceStatePerClass
	);
}
 
Example 4
Source Project: lams   Source File: AnnotationBinder.java    License: GNU General Public License v2.0 6 votes vote down vote up
public static Component createComponent(
		PropertyHolder propertyHolder,
		PropertyData inferredData,
		boolean isComponentEmbedded,
		boolean isIdentifierMapper,
		MetadataBuildingContext context) {
	Component comp = new Component( context, propertyHolder.getPersistentClass() );
	comp.setEmbedded( isComponentEmbedded );
	//yuk
	comp.setTable( propertyHolder.getTable() );
	//FIXME shouldn't identifier mapper use getClassOrElementName? Need to be checked.
	if ( isIdentifierMapper || ( isComponentEmbedded && inferredData.getPropertyName() == null ) ) {
		comp.setComponentClassName( comp.getOwner().getClassName() );
	}
	else {
		comp.setComponentClassName( inferredData.getClassOrElementName() );
	}
	return comp;
}
 
Example 5
protected AbstractComponentTuplizer(Component component) {
	setComponentClass( component );
	propertySpan = component.getPropertySpan();
	getters = new Getter[propertySpan];
	setters = new Setter[propertySpan];

	Iterator iter = component.getPropertyIterator();
	boolean foundCustomAccessor=false;
	int i = 0;
	while ( iter.hasNext() ) {
		Property prop = ( Property ) iter.next();
		getters[i] = buildGetter( component, prop );
		setters[i] = buildSetter( component, prop );
		if ( !prop.isBasicPropertyAccessor() ) {
			foundCustomAccessor = true;
		}
		i++;
	}
	hasCustomAccessors = foundCustomAccessor;
	instantiator = buildInstantiator( component );
}
 
Example 6
Source Project: lams   Source File: ModelBinder.java    License: GNU General Public License v2.0 6 votes vote down vote up
private void bindComponent(
		MappingDocument sourceDocument,
		EmbeddableSource embeddableSource,
		Component component,
		String containingClassName,
		String propertyName,
		String xmlNodeName,
		boolean isVirtual) {
	final String fullRole = embeddableSource.getAttributeRoleBase().getFullPath();
	final String explicitComponentClassName = extractExplicitComponentClassName( embeddableSource );

	bindComponent(
			sourceDocument,
			fullRole,
			embeddableSource,
			component,
			explicitComponentClassName,
			containingClassName,
			propertyName,
			isVirtual,
			embeddableSource.isDynamic(),
			xmlNodeName
	);
}
 
Example 7
public static void bindComposite(Element node, Component component, String path,
		boolean isNullable, Mappings mappings, java.util.Map inheritedMetas)
		throws MappingException {
	bindComponent(
			node,
			component,
			null,
			null,
			path,
			isNullable,
			false,
			mappings,
			inheritedMetas,
			false
		);
}
 
Example 8
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 9
public ComponentMetamodel(Component component) {
//		this.sessionFactory = sessionFactory;
		this.role = component.getRoleName();
		this.isKey = component.isKey();
		propertySpan = component.getPropertySpan();
		properties = new StandardProperty[propertySpan];
		Iterator itr = component.getPropertyIterator();
		int i = 0;
		while ( itr.hasNext() ) {
			Property property = ( Property ) itr.next();
			properties[i] = PropertyFactory.buildStandardProperty( property, false );
			propertyIndexes.put( property.getName(), new Integer( i ) );
			i++;
		}

		tuplizerMapping = new ComponentEntityModeToTuplizerMapping( component );
	}
 
Example 10
public void afterConfigurationBuilt(Mappings mappings, Dialect dialect) {
	super.afterConfigurationBuilt( mappings, dialect );
	// Oracle and Postgres do not have year() functions, so we need to
	// redefine the 'User.person.yob' formula
	//
	// consider temporary until we add the capability to define
	// mapping foprmulas which can use dialect-registered functions...
	PersistentClass user = mappings.getClass( User.class.getName() );
	org.hibernate.mapping.Property personProperty = user.getProperty( "person" );
	Component component = ( Component ) personProperty.getValue();
	Formula f = ( Formula ) component.getProperty( "yob" ).getValue().getColumnIterator().next();

	SQLFunction yearFunction = ( SQLFunction ) dialect.getFunctions().get( "year" );
	if ( yearFunction == null ) {
		// the dialect not know to support a year() function, so rely on the
		// ANSI SQL extract function
		f.setFormula( "extract( year from dob )");
	}
	else {
		List args = new ArrayList();
		args.add( "dob" );
		f.setFormula( yearFunction.render( args, null ) );
	}
}
 
Example 11
public void testProperCallbacks() {

		ValueVisitor vv = new ValueVisitorValidator();
		
		new Any(new Table()).accept(vv);
		new Array(new RootClass()).accept(vv);
		new Bag(new RootClass()).accept(vv);
		new Component(new RootClass()).accept(vv);
		new DependantValue(null,null).accept(vv);
		new IdentifierBag(null).accept(vv);
		new List(null).accept(vv);
		new ManyToOne(null).accept(vv);
		new Map(null).accept(vv);
		new OneToMany(null).accept(vv);
		new OneToOne(null, new RootClass() ).accept(vv);
		new PrimitiveArray(null).accept(vv);
		new Set(null).accept(vv);
		new SimpleValue().accept(vv);
	
		
	}
 
Example 12
Source Project: lams   Source File: ToOneFkSecondPass.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean isInPrimaryKey() {
	if ( entityClassName == null ) return false;
	final PersistentClass persistentClass = buildingContext.getMetadataCollector().getEntityBinding( entityClassName );
	Property property = persistentClass.getIdentifierProperty();
	if ( path == null ) {
		return false;
	}
	else if ( property != null) {
		//try explicit identifier property
		return path.startsWith( property.getName() + "." );
	}
	else {
		//try the embedded property
		//embedded property starts their path with 'id.' See PropertyPreloadedData( ) use when idClass != null in AnnotationSourceProcessor
		if ( path.startsWith( "id." ) ) {
			KeyValue valueIdentifier = persistentClass.getIdentifier();
			String localPath = path.substring( 3 );
			if ( valueIdentifier instanceof Component ) {
				Iterator it = ( (Component) valueIdentifier ).getPropertyIterator();
				while ( it.hasNext() ) {
					Property idProperty = (Property) it.next();
					if ( localPath.startsWith( idProperty.getName() ) ) return true;
				}

			}
		}
	}
	return false;
}
 
Example 13
Source Project: lams   Source File: TypeSafeActivator.java    License: GNU General Public License v2.0 5 votes vote down vote up
private static void applyDDL(
		String prefix,
		PersistentClass persistentClass,
		Class<?> clazz,
		ValidatorFactory factory,
		Set<Class<?>> groups,
		boolean activateNotNull,
		Dialect dialect) {
	final BeanDescriptor descriptor = factory.getValidator().getConstraintsForClass( clazz );
	//no bean level constraints can be applied, go to the properties

	for ( PropertyDescriptor propertyDesc : descriptor.getConstrainedProperties() ) {
		Property property = findPropertyByName( persistentClass, prefix + propertyDesc.getPropertyName() );
		boolean hasNotNull;
		if ( property != null ) {
			hasNotNull = applyConstraints(
					propertyDesc.getConstraintDescriptors(), property, propertyDesc, groups, activateNotNull, dialect
			);
			if ( property.isComposite() && propertyDesc.isCascaded() ) {
				Class<?> componentClass = ( (Component) property.getValue() ).getComponentClass();

				/*
				 * we can apply not null if the upper component let's us activate not null
				 * and if the property is not null.
				 * Otherwise, all sub columns should be left nullable
				 */
				final boolean canSetNotNullOnColumns = activateNotNull && hasNotNull;
				applyDDL(
						prefix + propertyDesc.getPropertyName() + ".",
						persistentClass, componentClass, factory, groups,
						canSetNotNullOnColumns,
                           dialect
				);
			}
			//FIXME add collection of components
		}
	}
}
 
Example 14
Source Project: lams   Source File: ComponentPropertyHolder.java    License: GNU General Public License v2.0 5 votes vote down vote up
public ComponentPropertyHolder(
			Component component,
			String path,
			PropertyData inferredData,
			PropertyHolder parent,
			MetadataBuildingContext context) {
		super( path, parent, inferredData.getPropertyClass(), context );
		final XProperty embeddedXProperty = inferredData.getProperty();
		setCurrentProperty( embeddedXProperty );
		this.component = component;
		this.isOrWithinEmbeddedId =
				parent.isOrWithinEmbeddedId()
						|| ( embeddedXProperty != null &&
						( embeddedXProperty.isAnnotationPresent( Id.class )
								|| embeddedXProperty.isAnnotationPresent( EmbeddedId.class ) ) );
		this.isWithinElementCollection = parent.isWithinElementCollection() ||
			parent instanceof CollectionPropertyHolder;

		if ( embeddedXProperty != null ) {
//			this.virtual = false;
			this.embeddedAttributeName = embeddedXProperty.getName();
			this.attributeConversionInfoMap = processAttributeConversions( embeddedXProperty );
		}
		else {
			// could be either:
			// 		1) virtual/dynamic component
			// 		2) collection element/key

			// temp
//			this.virtual = true;
			this.embeddedAttributeName = "";
			this.attributeConversionInfoMap = processAttributeConversions( inferredData.getClassOrElement() );
		}
	}
 
Example 15
public CopyIdentifierComponentSecondPass(
		Component comp,
		String referencedEntityName,
		Ejb3JoinColumn[] joinColumns,
		MetadataBuildingContext buildingContext) {
	this.component = comp;
	this.referencedEntityName = referencedEntityName;
	this.buildingContext = buildingContext;
	this.joinColumns = joinColumns;
}
 
Example 16
Source Project: lams   Source File: PropertyHolderBuilder.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * build a component property holder
 *
 * @param component component to wrap
 * @param path	  component path
 * @param context
 * @return PropertyHolder
 */
public static PropertyHolder buildPropertyHolder(
		Component component,
		String path,
		PropertyData inferredData,
		PropertyHolder parent,
		MetadataBuildingContext context) {
	return new ComponentPropertyHolder( component, path, inferredData, parent, context );
}
 
Example 17
Source Project: lams   Source File: MetadataContext.java    License: GNU General Public License v2.0 5 votes vote down vote up
private <X> void applyIdMetadata(PersistentClass persistentClass, EntityTypeImpl<X> jpaEntityType) {
	if ( persistentClass.hasIdentifierProperty() ) {
		final Property declaredIdentifierProperty = persistentClass.getDeclaredIdentifierProperty();
		if ( declaredIdentifierProperty != null ) {
			jpaEntityType.getBuilder().applyIdAttribute(
					attributeFactory.buildIdAttribute( jpaEntityType, declaredIdentifierProperty )
			);
		}
	}
	else if ( persistentClass.hasIdentifierMapper() ) {
		@SuppressWarnings("unchecked")
		Iterator<Property> propertyIterator = persistentClass.getIdentifierMapper().getPropertyIterator();
		Set<SingularAttribute<? super X, ?>> attributes = buildIdClassAttributes( jpaEntityType, propertyIterator );
		jpaEntityType.getBuilder().applyIdClassAttributes( attributes );
	}
	else {
		final KeyValue value = persistentClass.getIdentifier();
		if ( value instanceof Component ) {
			final Component component = (Component) value;
			if ( component.getPropertySpan() > 1 ) {
				//FIXME we are an Hibernate embedded id (ie not type)
			}
			else {
				//FIXME take care of declared vs non declared property
				jpaEntityType.getBuilder().applyIdAttribute(
						attributeFactory.buildIdAttribute(
								jpaEntityType,
								(Property) component.getPropertyIterator().next()
						)
				);
			}
		}
	}
}
 
Example 18
Source Project: lams   Source File: AbstractEntityPersister.java    License: GNU General Public License v2.0 5 votes vote down vote up
private void internalInitSubclassPropertyAliasesMap(String path, Iterator propertyIterator) {
	while ( propertyIterator.hasNext() ) {

		Property prop = (Property) propertyIterator.next();
		String propname = path == null ? prop.getName() : path + "." + prop.getName();
		if ( prop.isComposite() ) {
			Component component = (Component) prop.getValue();
			Iterator compProps = component.getPropertyIterator();
			internalInitSubclassPropertyAliasesMap( propname, compProps );
		}
		else {
			String[] aliases = new String[prop.getColumnSpan()];
			String[] cols = new String[prop.getColumnSpan()];
			Iterator colIter = prop.getColumnIterator();
			int l = 0;
			while ( colIter.hasNext() ) {
				Selectable thing = (Selectable) colIter.next();
				aliases[l] = thing.getAlias( getFactory().getDialect(), prop.getValue().getTable() );
				cols[l] = thing.getText( getFactory().getDialect() ); // TODO: skip formulas?
				l++;
			}

			subclassPropertyAliases.put( propname, aliases );
			subclassPropertyColumnNames.put( propname, cols );
		}
	}

}
 
Example 19
Source Project: lams   Source File: EntityMetamodel.java    License: GNU General Public License v2.0 5 votes vote down vote up
private static GenerationStrategyPair buildGenerationStrategyPair(
		final SessionFactoryImplementor sessionFactory,
		final Property mappingProperty) {
	final ValueGeneration valueGeneration = mappingProperty.getValueGenerationStrategy();
	if ( valueGeneration != null && valueGeneration.getGenerationTiming() != GenerationTiming.NEVER ) {
		// the property is generated in full. build the generation strategy pair.
		if ( valueGeneration.getValueGenerator() != null ) {
			// in-memory generation
			return new GenerationStrategyPair(
					FullInMemoryValueGenerationStrategy.create( valueGeneration )
			);
		}
		else {
			// in-db generation
			return new GenerationStrategyPair(
					create(
							sessionFactory,
							mappingProperty,
							valueGeneration
					)
			);
		}
	}
	else if ( mappingProperty.getValue() instanceof Component ) {
		final CompositeGenerationStrategyPairBuilder builder = new CompositeGenerationStrategyPairBuilder( mappingProperty );
		interpretPartialCompositeValueGeneration( sessionFactory, (Component) mappingProperty.getValue(), builder );
		return builder.buildPair();
	}

	return NO_GEN_PAIR;
}
 
Example 20
Source Project: lams   Source File: EntityMetamodel.java    License: GNU General Public License v2.0 5 votes vote down vote up
private static void interpretPartialCompositeValueGeneration(
		SessionFactoryImplementor sessionFactory,
		Component composite,
		CompositeGenerationStrategyPairBuilder builder) {
	Iterator subProperties = composite.getPropertyIterator();
	while ( subProperties.hasNext() ) {
		final Property subProperty = (Property) subProperties.next();
		builder.addPair( buildGenerationStrategyPair( sessionFactory, subProperty ) );
	}
}
 
Example 21
Source Project: lams   Source File: EntityMetamodel.java    License: GNU General Public License v2.0 5 votes vote down vote up
private void mapPropertyToIndex(Property prop, int i) {
	propertyIndexes.put( prop.getName(), i );
	if ( prop.getValue() instanceof Component ) {
		Iterator iter = ( (Component) prop.getValue() ).getPropertyIterator();
		while ( iter.hasNext() ) {
			Property subprop = (Property) iter.next();
			propertyIndexes.put(
					prop.getName() + '.' + subprop.getName(),
					i
				);
		}
	}
}
 
Example 22
/**
 * Construct an instance of the given tuplizer class.
 *
 * @param tuplizerClass The tuplizer class to instantiate
 * @param metadata The metadata for the component.
 *
 * @return The instantiated tuplizer
 *
 * @throws HibernateException if the {@link java.lang.reflect.Constructor#newInstance} call fails.
 */
public ComponentTuplizer constructTuplizer(Class<? extends ComponentTuplizer> tuplizerClass, Component metadata) {
	Constructor<? extends ComponentTuplizer> constructor = getProperConstructor( tuplizerClass );
	assert constructor != null : "Unable to locate proper constructor for tuplizer [" + tuplizerClass.getName() + "]";
	try {
		return constructor.newInstance( metadata );
	}
	catch ( Throwable t ) {
		throw new HibernateException( "Unable to instantiate default tuplizer [" + tuplizerClass.getName() + "]", t );
	}
}
 
Example 23
Source Project: lams   Source File: ComponentMetamodel.java    License: GNU General Public License v2.0 5 votes vote down vote up
private ComponentMetamodel(Component component, ComponentTuplizerFactory componentTuplizerFactory){
	this.role = component.getRoleName();
	this.isKey = component.isKey();
	propertySpan = component.getPropertySpan();
	properties = new StandardProperty[propertySpan];
	Iterator itr = component.getPropertyIterator();
	int i = 0;
	while ( itr.hasNext() ) {
		Property property = ( Property ) itr.next();
		properties[i] = PropertyFactory.buildStandardProperty( property, false );
		propertyIndexes.put( property.getName(), i );
		i++;
	}

	entityMode = component.hasPojoRepresentation() ? EntityMode.POJO : EntityMode.MAP;

	// todo : move this to SF per HHH-3517; also see HHH-1907 and ComponentMetamodel
	final String tuplizerClassName = component.getTuplizerImplClassName( entityMode );
	this.componentTuplizer = tuplizerClassName == null ? componentTuplizerFactory.constructDefaultTuplizer(
			entityMode,
			component
	) : componentTuplizerFactory.constructTuplizer( tuplizerClassName, component );

	final ConfigurationService cs = component.getMetadata().getMetadataBuildingOptions().getServiceRegistry()
			.getService(ConfigurationService.class);

	this.createEmptyCompositesEnabled = ConfigurationHelper.getBoolean(
			Environment.CREATE_EMPTY_COMPOSITES_ENABLED,
			cs.getSettings(),
			false
	);
}
 
Example 24
Source Project: lams   Source File: PojoComponentTuplizer.java    License: 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 25
Source Project: lams   Source File: PojoComponentTuplizer.java    License: GNU General Public License v2.0 5 votes vote down vote up
protected Instantiator buildInstantiator(Component component) {
	if ( component.isEmbedded() && ReflectHelper.isAbstractClass( this.componentClass ) ) {
		return new ProxiedInstantiator( this.componentClass );
	}
	if ( optimizer == null ) {
		return new PojoInstantiator( this.componentClass, null );
	}
	else {
		return new PojoInstantiator( this.componentClass, optimizer.getInstantiationOptimizer() );
	}
}
 
Example 26
Source Project: lams   Source File: ModelBinder.java    License: GNU General Public License v2.0 5 votes vote down vote up
private void finishBindingCompositeIdentifier(
		MappingDocument sourceDocument,
		RootClass rootEntityDescriptor,
		CompositeIdentifierSource identifierSource,
		Component cid,
		String propertyName) {
	if ( propertyName == null ) {
		rootEntityDescriptor.setEmbeddedIdentifier( cid.isEmbedded() );
		if ( cid.isEmbedded() ) {
			// todo : what is the implication of this?
			cid.setDynamic( !rootEntityDescriptor.hasPojoRepresentation() );
			/*
			 * Property prop = new Property(); prop.setName("id");
			 * prop.setPropertyAccessorName("embedded"); prop.setValue(id);
			 * entity.setIdentifierProperty(prop);
			 */
		}
	}
	else {
		Property prop = new Property();
		prop.setValue( cid );
		bindProperty(
				sourceDocument,
				( (IdentifierSourceAggregatedComposite) identifierSource ).getIdentifierAttributeSource(),
				prop
		);
		rootEntityDescriptor.setIdentifierProperty( prop );
		rootEntityDescriptor.setDeclaredIdentifierProperty( prop );
	}

	makeIdentifier(
			sourceDocument,
			identifierSource.getIdentifierGeneratorDescriptor(),
			null,
			cid
	);
}
 
Example 27
Source Project: lams   Source File: ModelBinder.java    License: GNU General Public License v2.0 5 votes vote down vote up
private void prepareComponentType(
		MappingDocument sourceDocument,
		String fullRole,
		Component componentBinding,
		String explicitComponentClassName,
		String containingClassName,
		String propertyName,
		boolean isVirtual,
		boolean isDynamic) {
}
 
Example 28
private static void bindCompositeId(Element idNode, RootClass entity, Mappings mappings,
		java.util.Map inheritedMetas) throws MappingException {
	String propertyName = idNode.attributeValue( "name" );
	Component id = new Component( entity );
	entity.setIdentifier( id );
	bindCompositeId( idNode, id, entity, propertyName, mappings, inheritedMetas );
	if ( propertyName == null ) {
		entity.setEmbeddedIdentifier( id.isEmbedded() );
		if ( id.isEmbedded() ) {
			// todo : what is the implication of this?
			id.setDynamic( !entity.hasPojoRepresentation() );
			/*
			 * Property prop = new Property(); prop.setName("id");
			 * prop.setPropertyAccessorName("embedded"); prop.setValue(id);
			 * entity.setIdentifierProperty(prop);
			 */
		}
	}
	else {
		Property prop = new Property();
		prop.setValue( id );
		bindProperty( idNode, prop, mappings, inheritedMetas );
		entity.setIdentifierProperty( prop );
	}

	makeIdentifier( idNode, id, mappings );

}
 
Example 29
private void internalInitSubclassPropertyAliasesMap(String path, Iterator propertyIterator) {
	while ( propertyIterator.hasNext() ) {

		Property prop = ( Property ) propertyIterator.next();
		String propname = path == null ? prop.getName() : path + "." + prop.getName();
		if ( prop.isComposite() ) {
			Component component = ( Component ) prop.getValue();
			Iterator compProps = component.getPropertyIterator();
			internalInitSubclassPropertyAliasesMap( propname, compProps );
		}
		else {
			String[] aliases = new String[prop.getColumnSpan()];
			String[] cols = new String[prop.getColumnSpan()];
			Iterator colIter = prop.getColumnIterator();
			int l = 0;
			while ( colIter.hasNext() ) {
				Selectable thing = ( Selectable ) colIter.next();
				aliases[l] = thing.getAlias( getFactory().getDialect(), prop.getValue().getTable() );
				cols[l] = thing.getText( getFactory().getDialect() ); // TODO: skip formulas?
				l++;
			}

			subclassPropertyAliases.put( propname, aliases );
			subclassPropertyColumnNames.put( propname, cols );
		}
	}

}
 
Example 30
private ValueInclusion determineInsertValueGenerationType(Property mappingProperty, StandardProperty runtimeProperty) {
	if ( runtimeProperty.isInsertGenerated() ) {
		return ValueInclusion.FULL;
	}
	else if ( mappingProperty.getValue() instanceof Component ) {
		if ( hasPartialInsertComponentGeneration( ( Component ) mappingProperty.getValue() ) ) {
			return ValueInclusion.PARTIAL;
		}
	}
	return ValueInclusion.NONE;
}