Java 类org.hibernate.mapping.Component 实例源码

项目:lams    文件:HbmBinder.java   
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
    );
}
项目:lams    文件:ClassPropertyHolder.java   
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 );
    }
}
项目:lams    文件:ComponentPropertyHolder.java   
public ComponentPropertyHolder(
        Component component,
        String path,
        PropertyData inferredData,
        PropertyHolder parent,
        Mappings mappings) {
    super( path, parent, inferredData.getPropertyClass(), mappings );
    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.virtual = embeddedXProperty == null;
    if ( !virtual ) {
        this.embeddedAttributeName = embeddedXProperty.getName();
        this.attributeConversionInfoMap = processAttributeConversions( embeddedXProperty );
    }
    else {
        embeddedAttributeName = "";
        this.attributeConversionInfoMap = Collections.emptyMap();
    }
}
项目:lams    文件:AnnotationBinder.java   
public static Component fillComponent(
        PropertyHolder propertyHolder,
        PropertyData inferredData,
        AccessType propertyAccessor,
        boolean isNullable,
        EntityBinder entityBinder,
        boolean isComponentEmbedded,
        boolean isIdentifierMapper,
        boolean inSecondPass,
        Mappings mappings,
        Map<XClass, InheritanceState> inheritanceStatePerClass) {
    return fillComponent(
            propertyHolder, inferredData, null, propertyAccessor,
            isNullable, entityBinder, isComponentEmbedded, isIdentifierMapper, inSecondPass, mappings,
            inheritanceStatePerClass
    );
}
项目:lams    文件:AnnotationBinder.java   
public static Component createComponent(
        PropertyHolder propertyHolder,
        PropertyData inferredData,
        boolean isComponentEmbedded,
        boolean isIdentifierMapper,
        Mappings mappings) {
    Component comp = new Component( mappings, 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() );
    }
    comp.setNodeName( inferredData.getPropertyName() );
    return comp;
}
项目:lams    文件:PojoInstantiator.java   
public PojoInstantiator(Component component, ReflectionOptimizer.InstantiationOptimizer optimizer) {
    this.mappedClass = component.getComponentClass();
    this.isAbstract = ReflectHelper.isAbstractClass( mappedClass );
    this.optimizer = optimizer;

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

    try {
        constructor = ReflectHelper.getDefaultConstructor(mappedClass);
    }
    catch ( PropertyNotFoundException pnfe ) {
        LOG.noDefaultConstructor(mappedClass.getName());
        constructor = null;
    }
}
项目:lams    文件:AbstractComponentTuplizer.java   
protected AbstractComponentTuplizer(Component 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 );
}
项目:lams    文件:ComponentMetamodel.java   
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(), i );
            i++;
        }

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

        // todo : move this to SF per HHH-3517; also see HHH-1907 and ComponentMetamodel
        final ComponentTuplizerFactory componentTuplizerFactory = new ComponentTuplizerFactory();
        final String tuplizerClassName = component.getTuplizerImplClassName( entityMode );
        this.componentTuplizer = tuplizerClassName == null ? componentTuplizerFactory.constructDefaultTuplizer(
                entityMode,
                component
        ) : componentTuplizerFactory.constructTuplizer( tuplizerClassName, component );
    }
项目:cacheonix-core    文件:HbmBinder.java   
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
        );
}
项目:cacheonix-core    文件:PojoInstantiator.java   
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;
    }
}
项目:cacheonix-core    文件:ComponentMetamodel.java   
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 );
    }
项目:cacheonix-core    文件:ValueVisitorTest.java   
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);


    }
项目:cacheonix-core    文件:ComponentTest.java   
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 ) );
    }
}
项目:hibernate-semantic-query    文件:EmbeddableMapperImpl.java   
@SuppressWarnings("unchecked")
public EmbeddableMapperImpl(
        PersisterCreationContext creationContext,
        ManagedTypeImplementor superTypeDescriptor,
        EmbeddableContainer compositeContainer,
        String locaName,
        Component embeddedMapping,
        MutabilityPlan mutabilityPlan,
        Comparator comparator,
        List<Column> allColumns) {
    super( resolveJtd( creationContext, embeddedMapping, mutabilityPlan, comparator ) );

    this.compositeContainer = compositeContainer;
    this.locaName = locaName;
    this.roleName = compositeContainer.getRolePrefix() + '.' + locaName;
    this.allColumns = allColumns;

    this.ormType = new EmbeddedTypeImpl( null, roleName, getJavaTypeDescriptor() );

    setTypeConfiguration( creationContext.getTypeConfiguration() );
    ormType.setTypeConfiguration( creationContext.getTypeConfiguration() );
}
项目:hibernate-semantic-query    文件:EmbeddableMapperImpl.java   
private static EmbeddableJavaTypeDescriptor resolveJtd(
        PersisterCreationContext creationContext,
        Component embeddedMapping,
        MutabilityPlan mutabilityPlan,
        Comparator comparator) {
    JavaTypeDescriptorRegistry jtdr = creationContext.getTypeConfiguration().getJavaTypeDescriptorRegistry();
    EmbeddableJavaTypeDescriptor jtd = (EmbeddableJavaTypeDescriptor) jtdr.getDescriptor( embeddedMapping.getType().getName() );
    if ( jtd == null ) {
        jtd = new EmbeddableJavaTypeDescriptorImpl(
                embeddedMapping.getType().getName(),
                embeddedMapping.getType().getReturnedClass(),
                null,
                mutabilityPlan,
                comparator
        );
        jtdr.addDescriptor( jtd );
    }
    return jtd;
}
项目:hibernate-semantic-query    文件:PersisterFactoryImpl.java   
@Override
public EmbeddableMapper createEmbeddablePersister(
        Component componentBinding,
        EmbeddableContainer source,
        String localName,
        PersisterCreationContext creationContext) throws HibernateException {
    final EmbeddableMapperImpl mapper = new EmbeddableMapperImpl(
            creationContext,
            null,
            source,
            localName,
            componentBinding,
            null,
            null,
            null
    );
    embeddableComponentMap.put( mapper, componentBinding );
    mapper.setTypeConfiguration( creationContext.getTypeConfiguration() );
    return mapper;
}
项目:hibernate-semantic-query    文件:OrmTypeHelper.java   
public static EmbeddedType convertComposite(
        PersisterCreationContext creationContext,
        String navigableName,
        Component navigableType,
        EmbeddableContainer source,
        TypeConfiguration typeConfiguration) {
    final String roleName = source.getRolePrefix() + navigableName;
    EmbeddableMapper mapper = typeConfiguration.findEmbeddableMapper( roleName );
    if ( mapper == null ) {
        mapper = creationContext.getPersisterFactory().createEmbeddablePersister(
                navigableType,
                source,
                navigableName,
                creationContext
        );
        creationContext.registerEmbeddablePersister( mapper );
    }
    return mapper.getOrmType();
}
项目:cagrid-core    文件:HibernateConfigTypesInformationResolver.java   
public List<String> getNestedInnerComponentNames(String parentClassname, String topLevelComponentName,
    String nestedComponentName, String innerComponentNamePrefix) {
    List<String> names = new ArrayList<String>();
    PersistentClass parent = configuration.getClassMapping(parentClassname);
    Property topLevelProperty = parent.getProperty(topLevelComponentName);
    Component topLevelComponent = (Component) topLevelProperty.getValue();
    Property nestedProperty = topLevelComponent.getProperty(nestedComponentName);
    Set nestedSet = (Set) nestedProperty.getValue();
    Component nestedComponent = (Component) nestedSet.getElement();
    Iterator<?> propertyIter = nestedComponent.getPropertyIterator();
    while (propertyIter.hasNext()) {
        Property prop = (Property) propertyIter.next();
        if (prop.getName().startsWith(innerComponentNamePrefix)) {
            names.add(prop.getName());
        }
    }
    return names;
}
项目:cagrid-core    文件:HibernateConfigTypesInformationResolver.java   
public List<String> getNestedInnerComponentNames(String parentClassname, String topLevelComponentName,
    String nestedComponentName, String innerComponentNamePrefix) {
    List<String> names = new ArrayList<String>();
    PersistentClass parent = configuration.getClassMapping(parentClassname);
    Property topLevelProperty = parent.getProperty(topLevelComponentName);
    Component topLevelComponent = (Component) topLevelProperty.getValue();
    Property nestedProperty = topLevelComponent.getProperty(nestedComponentName);
    Set nestedSet = (Set) nestedProperty.getValue();
    Component nestedComponent = (Component) nestedSet.getElement();
    Iterator<?> propertyIter = nestedComponent.getPropertyIterator();
    while (propertyIter.hasNext()) {
        Property prop = (Property) propertyIter.next();
        if (prop.getName().startsWith(innerComponentNamePrefix)) {
            names.add(prop.getName());
        }
    }
    return names;
}
项目:lams    文件:HbmBinder.java   
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( mappings, 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 );
        entity.setDeclaredIdentifierProperty( prop );
    }

    makeIdentifier( idNode, id, mappings );

}
项目:lams    文件:ToOneFkSecondPass.java   
@Override
   public boolean isInPrimaryKey() {
    if ( entityClassName == null ) return false;
    final PersistentClass persistentClass = mappings.getClass( 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;
}
项目:lams    文件:TypeSafeActivator.java   
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
        }
    }
}
项目:lams    文件:CopyIdentifierComponentSecondPass.java   
public CopyIdentifierComponentSecondPass(
        Component comp,
        String referencedEntityName,
        Ejb3JoinColumn[] joinColumns,
        Mappings mappings) {
    this.component = comp;
    this.referencedEntityName = referencedEntityName;
    this.mappings = mappings;
    this.joinColumns = joinColumns;
}
项目:lams    文件:PropertyHolderBuilder.java   
/**
 * build a component property holder
 *
 * @param component component to wrap
 * @param path    component path
 * @param mappings
 * @return PropertyHolder
 */
public static PropertyHolder buildPropertyHolder(
        Component component,
        String path,
        PropertyData inferredData,
        PropertyHolder parent,
        Mappings mappings) {
    return new ComponentPropertyHolder( component, path, inferredData, parent, mappings );
}
项目:lams    文件:AbstractEntityPersister.java   
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 );
        }
    }

}
项目:lams    文件:EntityMetamodel.java   
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;
}
项目:lams    文件:EntityMetamodel.java   
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 ) );
    }
}
项目:lams    文件:EntityMetamodel.java   
private ValueInclusion determineInsertValueGenerationType(Property mappingProperty, NonIdentifierAttribute runtimeProperty) {
    if ( isInsertGenerated( runtimeProperty ) ) {
        return ValueInclusion.FULL;
    }
    else if ( mappingProperty.getValue() instanceof Component ) {
        if ( hasPartialInsertComponentGeneration( ( Component ) mappingProperty.getValue() ) ) {
            return ValueInclusion.PARTIAL;
        }
    }
    return ValueInclusion.NONE;
}
项目:lams    文件:EntityMetamodel.java   
private boolean hasPartialInsertComponentGeneration(Component component) {
    Iterator subProperties = component.getPropertyIterator();
    while ( subProperties.hasNext() ) {
        final Property prop = ( Property ) subProperties.next();
        if ( isInsertGenerated( prop ) ) {
            return true;
        }
        else if ( prop.getValue() instanceof Component ) {
            if ( hasPartialInsertComponentGeneration( (Component) prop.getValue() ) ) {
                return true;
            }
        }
    }
    return false;
}
项目:lams    文件:EntityMetamodel.java   
private ValueInclusion determineUpdateValueGenerationType(Property mappingProperty, NonIdentifierAttribute runtimeProperty) {
    if ( isUpdateGenerated( runtimeProperty ) ) {
        return ValueInclusion.FULL;
    }
    else if ( mappingProperty.getValue() instanceof Component ) {
        if ( hasPartialUpdateComponentGeneration( ( Component ) mappingProperty.getValue() ) ) {
            return ValueInclusion.PARTIAL;
        }
    }
    return ValueInclusion.NONE;
}
项目:lams    文件:EntityMetamodel.java   
private boolean hasPartialUpdateComponentGeneration(Component component) {
    Iterator subProperties = component.getPropertyIterator();
    while ( subProperties.hasNext() ) {
        Property prop = (Property) subProperties.next();
        if ( isUpdateGenerated( prop ) ) {
            return true;
        }
        else if ( prop.getValue() instanceof Component ) {
            if ( hasPartialUpdateComponentGeneration( ( Component ) prop.getValue() ) ) {
                return true;
            }
        }
    }
    return false;
}
项目:lams    文件:EntityMetamodel.java   
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
                );
        }
    }
}
项目:lams    文件:EntityMetamodel.java   
private void mapPropertyToIndex(Attribute attribute, int i) {
    propertyIndexes.put( attribute.getName(), i );
    if ( attribute.isSingular() &&
            ( ( SingularAttribute ) attribute ).getSingularAttributeType().isComponent() ) {
        org.hibernate.metamodel.domain.Component component =
                ( org.hibernate.metamodel.domain.Component ) ( ( SingularAttribute ) attribute ).getSingularAttributeType();
        for ( Attribute subAttribute : component.attributes() ) {
            propertyIndexes.put(
                    attribute.getName() + '.' + subAttribute.getName(),
                    i
                );
        }
    }
}
项目:lams    文件:ComponentTuplizerFactory.java   
/**
 * 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 );
    }
}
项目:lams    文件:PojoComponentTuplizer.java   
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
        );
    }
}
项目:lams    文件:PojoComponentTuplizer.java   
protected Instantiator buildInstantiator(Component component) {
    if ( component.isEmbedded() && ReflectHelper.isAbstractClass( component.getComponentClass() ) ) {
        return new ProxiedInstantiator( component );
    }
    if ( optimizer == null ) {
        return new PojoInstantiator( component, null );
    }
    else {
        return new PojoInstantiator( component, optimizer.getInstantiationOptimizer() );
    }
}
项目:lams    文件:PojoComponentTuplizer.java   
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 );
    }
}
项目:cacheonix-core    文件:HbmBinder.java   
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 );

}
项目:cacheonix-core    文件:AbstractEntityPersister.java   
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 );
        }
    }

}
项目:cacheonix-core    文件:EntityMetamodel.java   
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;
}