Java 类org.hibernate.type.CompositeType 实例源码

项目:lams    文件:HibernateTraversableResolver.java   
private void addAssociationsToTheSetForOneProperty(String name, Type type, String prefix, SessionFactoryImplementor factory) {

        if ( type.isCollectionType() ) {
            CollectionType collType = (CollectionType) type;
            Type assocType = collType.getElementType( factory );
            addAssociationsToTheSetForOneProperty(name, assocType, prefix, factory);
        }
        //ToOne association
        else if ( type.isEntityType() || type.isAnyType() ) {
            associations.add( prefix + name );
        } else if ( type.isComponentType() ) {
            CompositeType componentType = (CompositeType) type;
            addAssociationsToTheSetForAllProperties(
                    componentType.getPropertyNames(),
                    componentType.getSubtypes(),
                    (prefix.equals( "" ) ? name : prefix + name) + ".",
                    factory);
        }
    }
项目:lams    文件:Example.java   
protected void addComponentTypedValues(
        String path, 
        Object component, 
        CompositeType type,
        List<TypedValue> list,
        Criteria criteria, 
        CriteriaQuery criteriaQuery) {
    if ( component != null ) {
        final String[] propertyNames = type.getPropertyNames();
        final Type[] subtypes = type.getSubtypes();
        final Object[] values = type.getPropertyValues( component, getEntityMode( criteria, criteriaQuery ) );
        for ( int i=0; i<propertyNames.length; i++ ) {
            final Object value = values[i];
            final Type subtype = subtypes[i];
            final String subpath = StringHelper.qualify( path, propertyNames[i] );
            if ( isPropertyIncluded( value, subpath, subtype ) ) {
                if ( subtype.isComponentType() ) {
                    addComponentTypedValues( subpath, value, (CompositeType) subtype, list, criteria, criteriaQuery );
                }
                else {
                    addPropertyTypedValue( value, subtype, list );
                }
            }
        }
    }
}
项目:lams    文件:EntityJoinWalker.java   
private void findKeyManyToOneTargetIndices(
        ArrayList<Integer> keyManyToOneTargetIndices,
        OuterJoinableAssociation joinWithCompositeId,
        CompositeType componentType) {
    for ( Type subType : componentType.getSubtypes() ) {
        if ( subType.isEntityType() ) {
            Integer index = locateKeyManyToOneTargetIndex( joinWithCompositeId, (EntityType) subType );
            if ( index != null ) {
                keyManyToOneTargetIndices.add( index );
            }
        }
        else if ( subType.isComponentType() ) {
            findKeyManyToOneTargetIndices(
                    keyManyToOneTargetIndices,
                    joinWithCompositeId,
                    (CompositeType) subType
            );
        }
    }
}
项目:lams    文件:EntityQuerySpaceImpl.java   
@Override
public ExpandingCompositeQuerySpace makeCompositeIdentifierQuerySpace() {
    final String compositeQuerySpaceUid = getUid() + "-id";
    final ExpandingCompositeQuerySpace rhs = getExpandingQuerySpaces().makeCompositeQuerySpace(
            compositeQuerySpaceUid,
            new CompositePropertyMapping(
                    (CompositeType) getEntityPersister().getIdentifierType(),
                    (PropertyMapping) getEntityPersister(),
                    getEntityPersister().getIdentifierPropertyName()
            ),
            canJoinsBeRequired()
    );
    final JoinDefinedByMetadata join = JoinHelper.INSTANCE.createCompositeJoin(
            this,
            EntityPersister.ENTITY_ID,
            rhs,
            canJoinsBeRequired(),
            (CompositeType) persister.getIdentifierType()
    );
    internalGetJoins().add( join );

    return rhs;
}
项目:lams    文件:QuerySpaceHelper.java   
public ExpandingCompositeQuerySpace makeCompositeQuerySpace(
        ExpandingQuerySpace lhsQuerySpace,
        AttributeDefinition attributeDefinition,
        String querySpaceUid,
        boolean shouldIncludeJoin) {
    final boolean required = lhsQuerySpace.canJoinsBeRequired() && !attributeDefinition.isNullable();
        return makeCompositeQuerySpace(
             lhsQuerySpace,
             new CompositePropertyMapping(
                     (CompositeType) attributeDefinition.getType(),
                     lhsQuerySpace.getPropertyMapping(),
                     attributeDefinition.getName()
             ),
             attributeDefinition.getName(),
             (CompositeType) attributeDefinition.getType(),
             querySpaceUid,
             required,
             shouldIncludeJoin
     );
}
项目:lams    文件:AbstractEntityReference.java   
/**
 * Builds just the first level of identifier description.  This will be either a simple id descriptor (String,
 * Long, etc) or some form of composite id (either encapsulated or not).
 *
 * @return the descriptor for the identifier
 */
private EntityIdentifierDescription buildIdentifierDescription() {
    final EntityIdentifierDefinition identifierDefinition = getEntityPersister().getEntityKeyDefinition();

    if ( identifierDefinition.isEncapsulated() ) {
        final EncapsulatedEntityIdentifierDefinition encapsulatedIdentifierDefinition = (EncapsulatedEntityIdentifierDefinition) identifierDefinition;
        final Type idAttributeType = encapsulatedIdentifierDefinition.getAttributeDefinition().getType();
        if ( ! CompositeType.class.isInstance( idAttributeType ) ) {
            return new SimpleEntityIdentifierDescriptionImpl();
        }
    }

    // if we get here, we know we have a composite identifier...
    final ExpandingCompositeQuerySpace querySpace = expandingEntityQuerySpace().makeCompositeIdentifierQuerySpace();
    return identifierDefinition.isEncapsulated()
            ? buildEncapsulatedCompositeIdentifierDescription( querySpace )
            : buildNonEncapsulatedCompositeIdentifierDescription( querySpace );
}
项目:lams    文件:AbstractEntityPersister.java   
private void prepareEntityIdentifierDefinition() {
    if ( entityIdentifierDefinition != null ) {
        return;
    }
    final Type idType = getIdentifierType();

    if ( !idType.isComponentType() ) {
        entityIdentifierDefinition =
                EntityIdentifierDefinitionHelper.buildSimpleEncapsulatedIdentifierDefinition( this );
        return;
    }

    final CompositeType cidType = (CompositeType) idType;
    if ( !cidType.isEmbedded() ) {
        entityIdentifierDefinition =
                EntityIdentifierDefinitionHelper.buildEncapsulatedCompositeIdentifierDefinition( this );
        return;
    }

    entityIdentifierDefinition =
            EntityIdentifierDefinitionHelper.buildNonEncapsulatedCompositeIdentifierDefinition( this );
}
项目:lams    文件:AbstractCollectionPersister.java   
private void initCollectionPropertyMap(String aliasName, Type type, String[] columnAliases, String[] columnNames) {

        collectionPropertyColumnAliases.put( aliasName, columnAliases );
        collectionPropertyColumnNames.put( aliasName, columnNames );

        if ( type.isComponentType() ) {
            CompositeType ct = (CompositeType) type;
            String[] propertyNames = ct.getPropertyNames();
            for ( int i = 0; i < propertyNames.length; i++ ) {
                String name = propertyNames[i];
                collectionPropertyColumnAliases.put( aliasName + "." + name, columnAliases[i] );
                collectionPropertyColumnNames.put( aliasName + "." + name, columnNames[i] );
            }
        }

    }
项目:lams    文件:CompositionBasedCompositionAttribute.java   
public CompositionBasedCompositionAttribute(
        AbstractCompositionAttribute source,
        SessionFactoryImplementor sessionFactory,
        int entityBasedAttributeNumber,
        String attributeName,
        CompositeType attributeType,
        int columnStartPosition,
        BaselineAttributeInformation baselineInfo) {
    super(
            source,
            sessionFactory,
            entityBasedAttributeNumber,
            attributeName,
            attributeType,
            columnStartPosition,
            baselineInfo
    );
}
项目:lams    文件:Cascade.java   
private void cascadeComponent(
        final Object parent,
        final Object child,
        final CompositeType componentType,
        final String componentPropertyName,
        final Object anything) {
    componentPathStackDepth++;
    final Object[] children = componentType.getPropertyValues( child, eventSource );
    final Type[] types = componentType.getSubtypes();
    for ( int i=0; i<types.length; i++ ) {
        final CascadeStyle componentPropertyStyle = componentType.getCascadeStyle( i );
        final String subPropertyName = componentType.getPropertyNames()[i];
        if ( componentPropertyStyle.doCascade( action ) ) {
            cascadeProperty(
                    parent,
                    children[i],
                    types[i],
                    componentPropertyStyle,
                    subPropertyName,
                    anything,
                    false
                );
        }
    }
    componentPathStackDepth--;
}
项目:lams    文件:Nullability.java   
/**
 * check sub elements-nullability. Returns property path that break
 * nullability or null if none
 *
 * @param propertyType type to check
 * @param value value to check
 *
 * @return property path
 * @throws HibernateException error while getting subcomponent values
 */
private String checkSubElementsNullability(Type propertyType, Object value) throws HibernateException {
    if ( propertyType.isComponentType() ) {
        return checkComponentNullability( value, (CompositeType) propertyType );
    }

    if ( propertyType.isCollectionType() ) {
        // persistent collections may have components
        final CollectionType collectionType = (CollectionType) propertyType;
        final Type collectionElementType = collectionType.getElementType( session.getFactory() );

        if ( collectionElementType.isComponentType() ) {
            // check for all components values in the collection
            final CompositeType componentType = (CompositeType) collectionElementType;
            final Iterator itr = CascadingActions.getLoadedElementsIterator( session, collectionType, value );
            while ( itr.hasNext() ) {
                final Object compositeElement = itr.next();
                if ( compositeElement != null ) {
                    return checkComponentNullability( compositeElement, componentType );
                }
            }
        }
    }

    return null;
}
项目:lams    文件:JavassistProxyFactory.java   
@Override
public void postInstantiate(
        final String entityName,
        final Class persistentClass,
        final Set interfaces,
        final Method getIdentifierMethod,
        final Method setIdentifierMethod,
        CompositeType componentIdType) throws HibernateException {
    this.entityName = entityName;
    this.persistentClass = persistentClass;
    this.interfaces = (Class[]) interfaces.toArray(NO_CLASSES);
    this.getIdentifierMethod = getIdentifierMethod;
    this.setIdentifierMethod = setIdentifierMethod;
    this.componentIdType = componentIdType;
    this.factory = JavassistLazyInitializer.getProxyFactory( persistentClass, this.interfaces );
    this.overridesEquals = ReflectHelper.overridesEquals(persistentClass);
}
项目:lams    文件:SerializableProxy.java   
public SerializableProxy(
        final String entityName,
        final Class persistentClass,
        final Class[] interfaces,
        final Serializable id,
        final Boolean readOnly,
        final Method getIdentifierMethod,
        final Method setIdentifierMethod,
        CompositeType componentIdType) {
    super( entityName, id, readOnly );
    this.persistentClass = persistentClass;
    this.interfaces = interfaces;
    if (getIdentifierMethod!=null) {
        getIdentifierMethodClass = getIdentifierMethod.getDeclaringClass();
        getIdentifierMethodName = getIdentifierMethod.getName();
    }
    if (setIdentifierMethod!=null) {
        setIdentifierMethodClass = setIdentifierMethod.getDeclaringClass();
        setIdentifierMethodName = setIdentifierMethod.getName();
        setIdentifierMethodParams = setIdentifierMethod.getParameterTypes();
    }
    this.componentIdType = componentIdType;
}
项目:lams    文件:BasicLazyInitializer.java   
protected BasicLazyInitializer(
        String entityName,
        Class persistentClass,
        Serializable id,
        Method getIdentifierMethod,
        Method setIdentifierMethod,
        CompositeType componentIdType,
        SessionImplementor session,
        boolean overridesEquals) {
    super(entityName, id, session);
    this.persistentClass = persistentClass;
    this.getIdentifierMethod = getIdentifierMethod;
    this.setIdentifierMethod = setIdentifierMethod;
    this.componentIdType = componentIdType;
    this.overridesEquals = overridesEquals;
}
项目:lams    文件:WrapVisitor.java   
@Override
Object processComponent(Object component, CompositeType componentType) throws HibernateException {
    if ( component != null ) {
        Object[] values = componentType.getPropertyValues( component, getSession() );
        Type[] types = componentType.getSubtypes();
        boolean substituteComponent = false;
        for ( int i = 0; i < types.length; i++ ) {
            Object result = processValue( values[i], types[i] );
            if ( result != null ) {
                values[i] = result;
                substituteComponent = true;
            }
        }
        if ( substituteComponent ) {
            componentType.setPropertyValues( component, values, EntityMode.POJO );
        }
    }

    return null;
}
项目:lams    文件:AbstractVisitor.java   
/**
 * Visit a property value. Dispatch to the
 * correct handler for the property type.
 * @param value
 * @param type
 * @throws HibernateException
 */
final Object processValue(Object value, Type type) throws HibernateException {

    if ( type.isCollectionType() ) {
        //even process null collections
        return processCollection( value, (CollectionType) type );
    }
    else if ( type.isEntityType() ) {
        return processEntity( value, (EntityType) type );
    }
    else if ( type.isComponentType() ) {
        return processComponent( value, (CompositeType) type );
    }
    else {
        return null;
    }
}
项目:lams    文件:Property.java   
public CascadeStyle getCascadeStyle() throws MappingException {
    Type type = value.getType();
    if ( type.isComponentType() ) {
        return getCompositeCascadeStyle( (CompositeType) type, cascade );
    }
    else if ( type.isCollectionType() ) {
        return getCollectionCascadeStyle( ( (Collection) value ).getElement().getType(), cascade );
    }
    else {
        return getCascadeStyle( cascade );          
    }
}
项目:lams    文件:Property.java   
private static CascadeStyle getCompositeCascadeStyle(CompositeType compositeType, String cascade) {
    if ( compositeType.isAnyType() ) {
        return getCascadeStyle( cascade );
    }
    int length = compositeType.getSubtypes().length;
    for ( int i=0; i<length; i++ ) {
        if ( compositeType.getCascadeStyle(i) != CascadeStyles.NONE ) {
            return CascadeStyles.ALL;
        }
    }
    return getCascadeStyle( cascade );
}
项目:lams    文件:Property.java   
private static CascadeStyle getCollectionCascadeStyle(Type elementType, String cascade) {
    if ( elementType.isComponentType() ) {
        return getCompositeCascadeStyle( (CompositeType) elementType, cascade );
    }
    else {
        return getCascadeStyle( cascade );
    }
}
项目:lams    文件:Example.java   
@Override
public TypedValue[] getTypedValues(Criteria criteria, CriteriaQuery criteriaQuery) {
    final EntityPersister meta = criteriaQuery.getFactory().getEntityPersister(
            criteriaQuery.getEntityName( criteria )
    );
    final String[] propertyNames = meta.getPropertyNames();
    final Type[] propertyTypes = meta.getPropertyTypes();

    final Object[] values = meta.getPropertyValues( exampleEntity );
    final List<TypedValue> list = new ArrayList<TypedValue>();
    for ( int i=0; i<propertyNames.length; i++ ) {
        final Object value = values[i];
        final Type type = propertyTypes[i];
        final String name = propertyNames[i];

        final boolean isVersionProperty = i == meta.getVersionProperty();

        if ( ! isVersionProperty && isPropertyIncluded( value, name, type ) ) {
            if ( propertyTypes[i].isComponentType() ) {
                addComponentTypedValues( name, value, (CompositeType) type, list, criteria, criteriaQuery );
            }
            else {
                addPropertyTypedValue( value, type, list );
            }
        }
    }

    return list.toArray( new TypedValue[ list.size() ] );
}
项目:lams    文件:Example.java   
protected void appendComponentCondition(
        String path,
        Object component,
        CompositeType type,
        Criteria criteria,
        CriteriaQuery criteriaQuery,
        StringBuilder buf) {
    if ( component != null ) {
        final String[] propertyNames = type.getPropertyNames();
        final Object[] values = type.getPropertyValues( component, getEntityMode( criteria, criteriaQuery ) );
        final Type[] subtypes = type.getSubtypes();
        for ( int i=0; i<propertyNames.length; i++ ) {
            final String subPath = StringHelper.qualify( path, propertyNames[i] );
            final Object value = values[i];
            if ( isPropertyIncluded( value, subPath, subtypes[i] ) ) {
                final Type subtype = subtypes[i];
                if ( subtype.isComponentType() ) {
                    appendComponentCondition(
                            subPath,
                            value,
                            (CompositeType) subtype,
                            criteria,
                            criteriaQuery,
                            buf
                    );
                }
                else {
                    appendPropertyCondition(
                            subPath,
                            value,
                            criteria,
                            criteriaQuery,
                            buf
                    );
                }
            }
        }
    }
}
项目:lams    文件:EntityJoinWalker.java   
private boolean hasAssociation(CompositeType componentType) {
    for ( Type subType : componentType.getSubtypes() ) {
        if ( subType.isEntityType() ) {
            return true;
        }
        else if ( subType.isComponentType() && hasAssociation( ( (CompositeType) subType ) ) ) {
            return true;
        }
    }
    return false;
}
项目:lams    文件:ResultSetProcessorHelper.java   
public EntityKey interpretEntityKey(
        SessionImplementor session,
        String optionalEntityName,
        Serializable optionalId,
        Object optionalObject) {
    if ( optionalEntityName != null ) {
        final EntityPersister entityPersister;
        if ( optionalObject != null ) {
            entityPersister = session.getEntityPersister( optionalEntityName, optionalObject );
        }
        else {
            entityPersister = session.getFactory().getEntityPersister( optionalEntityName );
        }
        if ( entityPersister.isInstance( optionalId ) &&
                !entityPersister.getEntityMetamodel().getIdentifierProperty().isVirtual() &&
                entityPersister.getEntityMetamodel().getIdentifierProperty().isEmbedded() ) {
            // non-encapsulated composite identifier
            final Serializable identifierState = ((CompositeType) entityPersister.getIdentifierType()).getPropertyValues(
                    optionalId,
                    session
            );
            return session.generateEntityKey( identifierState, entityPersister );
        }
        else {
            return session.generateEntityKey( optionalId, entityPersister );
        }
    }
    else {
        return null;
    }
}
项目:lams    文件:CompositePropertyMapping.java   
/**
 * Builds a CompositePropertyMapping
 *
 * @param compositeType The composite being described by this PropertyMapping
 * @param parentPropertyMapping The PropertyMapping of our parent (composites have to have a parent/owner)
 * @param parentPropertyName The name of this composite within the parentPropertyMapping
 */
public CompositePropertyMapping(
        CompositeType compositeType,
        PropertyMapping parentPropertyMapping,
        String parentPropertyName) {
    this.compositeType = compositeType;
    this.parentPropertyMapping = parentPropertyMapping;
    this.parentPropertyName = parentPropertyName;
}
项目:lams    文件:QuerySpaceHelper.java   
public ExpandingCompositeQuerySpace makeCompositeQuerySpace(
        ExpandingQuerySpace lhsQuerySpace,
        CompositePropertyMapping compositePropertyMapping,
        String attributeName,
        CompositeType attributeType,
        String querySpaceUid,
        boolean required,
        boolean shouldIncludeJoin) {

    final ExpandingCompositeQuerySpace rhs = lhsQuerySpace.getExpandingQuerySpaces().makeCompositeQuerySpace(
            querySpaceUid,
            compositePropertyMapping,
            required
    );

    if ( shouldIncludeJoin ) {
        final JoinDefinedByMetadata join = JoinHelper.INSTANCE.createCompositeJoin(
                lhsQuerySpace,
                attributeName,
                rhs,
                required,
                attributeType
        );
        lhsQuerySpace.addJoin( join );
    }

    return rhs;
}
项目:lams    文件:JoinHelper.java   
public JoinDefinedByMetadata createCompositeJoin(
        QuerySpace leftHandSide,
        String lhsPropertyName,
        CompositeQuerySpace rightHandSide,
        boolean rightHandSideRequired,
        CompositeType joinedPropertyType) {
    return new JoinImpl(
            leftHandSide,
            lhsPropertyName,
            rightHandSide,
            null,
            joinedPropertyType,
            rightHandSideRequired
    );
}
项目:lams    文件:AbstractEntityReference.java   
private NonEncapsulatedEntityIdentifierDescription buildNonEncapsulatedCompositeIdentifierDescription(
        ExpandingCompositeQuerySpace compositeQuerySpace) {
    return new NonEncapsulatedEntityIdentifierDescription(
            this,
            compositeQuerySpace,
            (CompositeType) getEntityPersister().getIdentifierType(),
            getPropertyPath().append( EntityPersister.ENTITY_ID )
    );
}
项目:lams    文件:AbstractEntityReference.java   
private EncapsulatedEntityIdentifierDescription buildEncapsulatedCompositeIdentifierDescription(
        ExpandingCompositeQuerySpace compositeQuerySpace) {
    return new EncapsulatedEntityIdentifierDescription(
            this,
            compositeQuerySpace,
            (CompositeType) getEntityPersister().getIdentifierType(),
            getPropertyPath().append( EntityPersister.ENTITY_ID )
    );
}
项目:lams    文件:AbstractCompositeEntityIdentifierDescription.java   
protected AbstractCompositeEntityIdentifierDescription(
        EntityReference entityReference,
        ExpandingCompositeQuerySpace compositeQuerySpace,
        CompositeType identifierType,
        PropertyPath propertyPath) {
    super( compositeQuerySpace, false, propertyPath );
    this.entityReference = entityReference;
    this.identifierType = identifierType;
}
项目:lams    文件:NonEncapsulatedEntityIdentifierDescription.java   
/**
 * Build a non-encapsulated version of a composite EntityIdentifierDescription
 *
 * @param entityReference The entity whose identifier we describe
 * @param compositeQuerySpace The query space we are mapped to.
 * @param compositeType The type representing this composition
 * @param propertyPath The property path (informational)
 */
public NonEncapsulatedEntityIdentifierDescription(
        EntityReference entityReference,
        ExpandingCompositeQuerySpace compositeQuerySpace,
        CompositeType compositeType,
        PropertyPath propertyPath) {
    super(
            entityReference,
            compositeQuerySpace,
            compositeType,
            propertyPath
    );
}
项目:lams    文件:CompositeElementPropertyMapping.java   
public CompositeElementPropertyMapping(
        String[] elementColumns,
        String[] elementColumnReaders,
        String[] elementColumnReaderTemplates, 
        String[] elementFormulaTemplates, 
        CompositeType compositeType,
        Mapping factory)
throws MappingException {

    this.compositeType = compositeType;

    initComponentPropertyPaths(null, compositeType, elementColumns, elementColumnReaders,
            elementColumnReaderTemplates, elementFormulaTemplates, factory);

}
项目:lams    文件:CompositionSingularSubAttributesHelper.java   
/**
 * Get composite ID sub-attribute definitions.
 *
 * @param entityPersister - the entity persister.
 *
 * @return composite ID sub-attribute definitions.
 */
public static Iterable<AttributeDefinition> getIdentifierSubAttributes(AbstractEntityPersister entityPersister) {
    return getSingularSubAttributes(
            entityPersister,
            entityPersister,
            (CompositeType) entityPersister.getIdentifierType(),
            entityPersister.getTableName(),
            entityPersister.getRootTableIdentifierColumnNames()
    );
}
项目:lams    文件:CompositionSingularSubAttributesHelper.java   
/**
 * Get sub-attribute definitions for a composite collection element.
 * @param compositionElementDefinition - composite collection element definition.
 * @return sub-attribute definitions for a composite collection element.
 */
public static Iterable<AttributeDefinition> getCompositeCollectionElementSubAttributes(
        CompositeCollectionElementDefinition compositionElementDefinition) {
    final QueryableCollection collectionPersister =
            (QueryableCollection) compositionElementDefinition.getCollectionDefinition().getCollectionPersister();
    return getSingularSubAttributes(
            compositionElementDefinition.getSource(),
            (OuterJoinLoadable) collectionPersister.getOwnerEntityPersister(),
            (CompositeType) collectionPersister.getElementType(),
            collectionPersister.getTableName(),
            collectionPersister.getElementColumnNames()
    );
}
项目:lams    文件:CompositionSingularSubAttributesHelper.java   
public static Iterable<AttributeDefinition> getCompositeCollectionIndexSubAttributes(CompositeCollectionElementDefinition compositionElementDefinition){
    final QueryableCollection collectionPersister =
            (QueryableCollection) compositionElementDefinition.getCollectionDefinition().getCollectionPersister();
    return getSingularSubAttributes(
            compositionElementDefinition.getSource(),
            (OuterJoinLoadable) collectionPersister.getOwnerEntityPersister(),
            (CompositeType) collectionPersister.getIndexType(),
            collectionPersister.getTableName(),
            collectionPersister.getIndexColumnNames()
    );
}
项目:lams    文件:EntityBasedCompositionAttribute.java   
public EntityBasedCompositionAttribute(
        EntityPersister source,
        SessionFactoryImplementor factory,
        int attributeNumber,
        String attributeName,
        CompositeType attributeType,
        BaselineAttributeInformation baselineInfo) {
    super( source, factory, attributeNumber, attributeName, attributeType, 0, baselineInfo );
}
项目:lams    文件:EntityMetamodel.java   
private boolean indicatesCollection(Type type) {
    if ( type.isCollectionType() ) {
        return true;
    }
    else if ( type.isComponentType() ) {
        Type[] subtypes = ( (CompositeType) type ).getSubtypes();
        for ( int i = 0; i < subtypes.length; i++ ) {
            if ( indicatesCollection( subtypes[i] ) ) {
                return true;
            }
        }
    }
    return false;
}
项目:lams    文件:AbstractEntityTuplizer.java   
@Override
public void setIdentifier(Object entity, Serializable id, SessionImplementor session) {
    if ( entityMetamodel.getIdentifierProperty().isEmbedded() ) {
        if ( entity != id ) {
            CompositeType copier = (CompositeType) entityMetamodel.getIdentifierProperty().getType();
            copier.setPropertyValues( entity, copier.getPropertyValues( id, getEntityMode() ), getEntityMode() );
        }
    }
    else if ( idSetter != null ) {
        idSetter.set( entity, id, getFactory() );
    }
    else if ( identifierMapperType != null ) {
        mappedIdentifierValueMarshaller.setIdentifier( entity, id, getEntityMode(), session );
    }
}
项目:lams    文件:AbstractCompositionAttribute.java   
protected AbstractCompositionAttribute(
        AttributeSource source,
        SessionFactoryImplementor sessionFactory,
        int entityBasedAttributeNumber,
        String attributeName,
        CompositeType attributeType,
        int columnStartPosition,
        BaselineAttributeInformation baselineInfo) {
    super( source, sessionFactory, entityBasedAttributeNumber, attributeName, attributeType, baselineInfo );
    this.columnStartPosition = columnStartPosition;
}
项目:lams    文件:ForeignKeys.java   
/**
 * Return null if the argument is an "unsaved" entity (ie. one with no existing database row), or the
 * input argument otherwise.  This is how Hibernate avoids foreign key constraint violations.
 *
 * @param value An entity attribute value
 * @param type An entity attribute type
 *
 * @return {@code null} if the argument is an unsaved entity; otherwise return the argument.
 */
private Object nullifyTransientReferences(final Object value, final Type type) {
    if ( value == null ) {
        return null;
    }
    else if ( type.isEntityType() ) {
        final EntityType entityType = (EntityType) type;
        if ( entityType.isOneToOne() ) {
            return value;
        }
        else {
            final String entityName = entityType.getAssociatedEntityName();
            return isNullifiable( entityName, value ) ? null : value;
        }
    }
    else if ( type.isAnyType() ) {
        return isNullifiable( null, value ) ? null : value;
    }
    else if ( type.isComponentType() ) {
        final CompositeType actype = (CompositeType) type;
        final Object[] subvalues = actype.getPropertyValues( value, session );
        final Type[] subtypes = actype.getSubtypes();
        boolean substitute = false;
        for ( int i = 0; i < subvalues.length; i++ ) {
            final Object replacement = nullifyTransientReferences( subvalues[i], subtypes[i] );
            if ( replacement != subvalues[i] ) {
                substitute = true;
                subvalues[i] = replacement;
            }
        }
        if ( substitute ) {
            // todo : need to account for entity mode on the CompositeType interface :(
            actype.setPropertyValues( value, subvalues, EntityMode.POJO );
        }
        return value;
    }
    else {
        return value;
    }
}
项目:lams    文件:Nullability.java   
/**
 * check component nullability. Returns property path that break
 * nullability or null if none
 *
 * @param value component properties
 * @param compositeType component not-nullable type
 *
 * @return property path
 * @throws HibernateException error while getting subcomponent values
 */
private String checkComponentNullability(Object value, CompositeType compositeType) throws HibernateException {
    // IMPL NOTE : we currently skip checking "any" and "many to any" mappings.
    //
    // This is not the best solution.  But atm there is a mismatch between AnyType#getPropertyNullability
    // and the fact that cascaded-saves for "many to any" mappings are not performed until after this nullability
    // check.  So the nullability check fails for transient entity elements with generated identifiers because
    // the identifier is not yet generated/assigned (is null)
    //
    // The more correct fix would be to cascade saves of the many-to-any elements before the Nullability checking

    if ( compositeType.isAnyType() ) {
        return null;
    }

    final boolean[] nullability = compositeType.getPropertyNullability();
    if ( nullability != null ) {
        //do the test
        final Object[] subValues = compositeType.getPropertyValues( value, session );
        final Type[] propertyTypes = compositeType.getSubtypes();
        for ( int i = 0; i < subValues.length; i++ ) {
            final Object subValue = subValues[i];
            if ( !nullability[i] && subValue==null ) {
                return compositeType.getPropertyNames()[i];
            }
            else if ( subValue != null ) {
                final String breakProperties = checkSubElementsNullability( propertyTypes[i], subValue );
                if ( breakProperties != null ) {
                    return buildPropertyPath( compositeType.getPropertyNames()[i], breakProperties );
                }
            }
        }
    }
    return null;
}