Example usage for org.hibernate.mapping Property getName

List of usage examples for org.hibernate.mapping Property getName

Introduction

In this page you can find the example usage for org.hibernate.mapping Property getName.

Prototype

public String getName() 

Source Link

Usage

From source file:org.broadleafcommerce.openadmin.server.dao.DynamicEntityDaoImpl.java

License:Apache License

@SuppressWarnings("unchecked")
protected Map<String, FieldMetadata> getPropertiesForEntityClass(Class<?> targetClass, ForeignKey foreignField,
        String[] additionalNonPersistentProperties, ForeignKey[] additionalForeignFields,
        MergedPropertyType mergedPropertyType, Boolean populateManyToOneFields, String[] includeFields,
        String[] excludeFields, String configurationKey, String ceilingEntityFullyQualifiedClassname,
        List<Class<?>> parentClasses, String prefix, Boolean isParentExcluded)
        throws ClassNotFoundException, SecurityException, IllegalArgumentException, NoSuchMethodException,
        IllegalAccessException, InvocationTargetException {
    Map<String, FieldPresentationAttributes> presentationAttributes = getFieldPresentationAttributes(
            targetClass);//w w w  .  j a v  a2s  .  co  m
    if (isParentExcluded) {
        for (String key : presentationAttributes.keySet()) {
            presentationAttributes.get(key).setExcluded(true);
        }
    }

    Map idMetadata = getIdMetadata(targetClass);
    Map<String, FieldMetadata> fields = new HashMap<String, FieldMetadata>();
    String idProperty = (String) idMetadata.get("name");
    List<String> propertyNames = getPropertyNames(targetClass);
    propertyNames.add(idProperty);
    Type idType = (Type) idMetadata.get("type");
    List<Type> propertyTypes = getPropertyTypes(targetClass);
    propertyTypes.add(idType);

    PersistentClass persistentClass = getPersistentClass(targetClass.getName());
    Iterator<Property> testIter = persistentClass.getPropertyIterator();
    List<Property> propertyList = new ArrayList<Property>();

    //check the properties for problems
    while (testIter.hasNext()) {
        Property property = testIter.next();
        if (property.getName().indexOf(".") >= 0) {
            throw new IllegalArgumentException(
                    "Properties from entities that utilize a period character ('.') in their name are incompatible with this system. The property name in question is: ("
                            + property.getName() + ") from the class: (" + targetClass.getName() + ")");
        }
        propertyList.add(property);
    }

    buildProperties(targetClass, foreignField, additionalForeignFields, additionalNonPersistentProperties,
            mergedPropertyType, presentationAttributes, propertyList, fields, propertyNames, propertyTypes,
            idProperty, populateManyToOneFields, includeFields, excludeFields, configurationKey,
            ceilingEntityFullyQualifiedClassname, parentClasses, prefix, isParentExcluded);
    FieldPresentationAttributes presentationAttribute = new FieldPresentationAttributes();
    presentationAttribute.setExplicitFieldType(SupportedFieldType.STRING);
    presentationAttribute.setVisibility(VisibilityEnum.HIDDEN_ALL);
    if (!ArrayUtils.isEmpty(additionalNonPersistentProperties)) {
        Class<?>[] entities = getAllPolymorphicEntitiesFromCeiling(targetClass);
        for (String additionalNonPersistentProperty : additionalNonPersistentProperties) {
            if (StringUtils.isEmpty(prefix)
                    || (!StringUtils.isEmpty(prefix) && additionalNonPersistentProperty.startsWith(prefix))) {
                String myAdditionalNonPersistentProperty = additionalNonPersistentProperty;
                //get final property if this is a dot delimited property
                int finalDotPos = additionalNonPersistentProperty.lastIndexOf('.');
                if (finalDotPos >= 0) {
                    myAdditionalNonPersistentProperty = myAdditionalNonPersistentProperty
                            .substring(finalDotPos + 1, myAdditionalNonPersistentProperty.length());
                }
                //check all the polymorphic types on this target class to see if the end property exists
                Field testField = null;
                Method testMethod = null;
                for (Class<?> clazz : entities) {
                    try {
                        testMethod = clazz.getMethod(myAdditionalNonPersistentProperty);
                        if (testMethod != null) {
                            break;
                        }
                    } catch (NoSuchMethodException e) {
                        //do nothing - method does not exist
                    }
                    testField = getFieldManager().getField(clazz, myAdditionalNonPersistentProperty);
                    if (testField != null) {
                        break;
                    }
                }
                //if the property exists, add it to the metadata for this class
                if (testField != null || testMethod != null) {
                    fields.put(additionalNonPersistentProperty,
                            getFieldMetadata(prefix, additionalNonPersistentProperty, propertyList,
                                    SupportedFieldType.STRING, null, targetClass, presentationAttribute,
                                    mergedPropertyType));
                }
            }
        }
    }

    return fields;
}

From source file:org.broadleafcommerce.openadmin.server.dao.provider.metadata.DefaultFieldMetadataProvider.java

License:Apache License

@Override
public FieldProviderResponse addMetadataFromMappingData(
        AddMetadataFromMappingDataRequest addMetadataFromMappingDataRequest, FieldMetadata metadata) {
    BasicFieldMetadata fieldMetadata = (BasicFieldMetadata) metadata;
    fieldMetadata.setFieldType(addMetadataFromMappingDataRequest.getType());
    fieldMetadata.setSecondaryType(addMetadataFromMappingDataRequest.getSecondaryType());
    if (addMetadataFromMappingDataRequest.getRequestedEntityType() != null
            && !addMetadataFromMappingDataRequest.getRequestedEntityType().isCollectionType()) {
        Column column = null;/* w  ww.  j  a v  a 2s  . co  m*/
        for (Property property : addMetadataFromMappingDataRequest.getComponentProperties()) {
            if (property.getName().equals(addMetadataFromMappingDataRequest.getPropertyName())) {
                Object columnObject = property.getColumnIterator().next();
                if (columnObject instanceof Column) {
                    column = (Column) columnObject;
                }
                break;
            }
        }
        if (column != null) {
            fieldMetadata.setLength(column.getLength());
            fieldMetadata.setScale(column.getScale());
            fieldMetadata.setPrecision(column.getPrecision());
            fieldMetadata.setRequired(!column.isNullable());
            fieldMetadata.setUnique(column.isUnique());
        }
        fieldMetadata.setForeignKeyCollection(false);
    } else {
        fieldMetadata.setForeignKeyCollection(true);
    }
    fieldMetadata.setMutable(true);
    fieldMetadata.setMergedPropertyType(addMetadataFromMappingDataRequest.getMergedPropertyType());
    if (SupportedFieldType.BROADLEAF_ENUMERATION.equals(addMetadataFromMappingDataRequest.getType())) {
        try {
            setupBroadleafEnumeration(fieldMetadata.getBroadleafEnumeration(), fieldMetadata,
                    addMetadataFromMappingDataRequest.getDynamicEntityDao());
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
    return FieldProviderResponse.HANDLED;
}

From source file:org.codehaus.groovy.grails.orm.hibernate.cfg.GrailsDomainBinderTests.java

License:Apache License

/**
 * Tests that single- and multi-column user type mappings work
 * correctly. Also Checks that the "sqlType" property is honoured.
 *///from   ww  w  .j  av a 2  s . co  m
public void testUserTypeMappings() {
    DefaultGrailsDomainConfiguration config = getDomainConfig(MULTI_COLUMN_USER_TYPE_DEFINITION);
    PersistentClass persistentClass = config.getClassMapping("Item");

    // First check the "name" property and its associated column.
    Property nameProperty = persistentClass.getProperty("name");
    assertEquals(1, nameProperty.getColumnSpan());
    assertEquals("name", nameProperty.getName());

    Column column = (Column) nameProperty.getColumnIterator().next();
    assertEquals("s_name", column.getName());
    assertEquals("text", column.getSqlType());

    // Next the "other" property.
    Property otherProperty = persistentClass.getProperty("other");
    assertEquals(1, otherProperty.getColumnSpan());
    assertEquals("other", otherProperty.getName());

    column = (Column) otherProperty.getColumnIterator().next();
    assertEquals("other", column.getName());
    assertEquals("wrapper-characters", column.getSqlType());
    assertEquals(MyUserType.class.getName(), column.getValue().getType().getName());
    assertTrue(column.getValue() instanceof SimpleValue);
    SimpleValue v = (SimpleValue) column.getValue();
    assertEquals("myParam1", v.getTypeParameters().get("param1"));
    assertEquals("myParam2", v.getTypeParameters().get("param2"));

    // And now for the "price" property, which should have two
    // columns.
    Property priceProperty = persistentClass.getProperty("price");
    assertEquals(2, priceProperty.getColumnSpan());
    assertEquals("price", priceProperty.getName());

    Iterator colIter = priceProperty.getColumnIterator();
    column = (Column) colIter.next();
    assertEquals("value", column.getName());
    assertNull("SQL type should have been 'null' for 'value' column.", column.getSqlType());

    column = (Column) colIter.next();
    assertEquals("currency_code", column.getName());
    assertEquals("text", column.getSqlType());
}

From source file:org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDORevisionTuplizer.java

License:Open Source License

@Override
protected Getter buildPropertyGetter(Property mappedProperty, PersistentClass mappedEntity) {
    initEClass(mappedEntity);/*from  www  .ja  v  a2s.co  m*/
    if (TRACER.isEnabled()) {
        TRACER.trace("Building property getter for " + eClass.getName() + "." + mappedProperty.getName()); //$NON-NLS-1$ //$NON-NLS-2$
    }

    if (mappedProperty.isBackRef()) {
        return mappedProperty.getGetter(mappedEntity.getMappedClass());
    }
    final CDOPropertyGetter getter;
    if (mappedProperty == mappedEntity.getIdentifierProperty()) {
        getter = new CDOIDPropertyGetter(this, mappedProperty.getName());
    } else if (mappedProperty.getMetaAttribute("version") != null) {
        getter = new CDOVersionPropertyGetter(this, mappedProperty.getName());
    } else if (mappedProperty.getName().compareTo(CDOHibernateConstants.RESOURCE_PROPERTY) == 0) {
        getter = new CDOResourceIDGetter(this, mappedProperty.getName());
    } else if (mappedProperty.getName().compareTo(CDOHibernateConstants.CONTAINER_PROPERTY) == 0) {
        getter = new CDOContainerGetter(this, mappedProperty.getName());
    } else if (mappedProperty.getName().compareTo(CDOHibernateConstants.COMMITTIMESTAMP_PROPERTY) == 0) {
        getter = new CDOBranchTimeStampGetter(this, mappedProperty.getName());
    } else {
        EStructuralFeature feature = getEClass().getEStructuralFeature(mappedProperty.getName());
        if (feature instanceof EReference && feature.isMany()
                && HibernateUtil.getInstance().isCDOResourceContents(feature)) {
            getter = new CDOManyAttributeGetter(this, mappedProperty.getName());
        } else if (feature instanceof EReference && feature.isMany()) {
            getter = new CDOManyReferenceGetter(this, mappedProperty.getName());
        } else if (feature instanceof EReference) {
            getter = new CDOReferenceGetter(this, mappedProperty.getName());
        } else if (feature instanceof EAttribute && feature.isMany()) {
            getter = new CDOManyAttributeGetter(this, mappedProperty.getName());
        } else {
            getter = new CDOPropertyGetter(this, mappedProperty.getName());
        }
    }

    HibernateStore hbStore = HibernateStore.getCurrentHibernateStore();
    getter.setPersistenceOptions(hbStore.getCDODataStore().getPersistenceOptions());
    return getter;
}

From source file:org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDORevisionTuplizer.java

License:Open Source License

@Override
protected Setter buildPropertySetter(Property mappedProperty, PersistentClass mappedEntity) {
    initEClass(mappedEntity);/* w  w  w. j a v a2s .  co m*/
    if (TRACER.isEnabled()) {
        TRACER.trace("Building property setter for " + eClass.getName() + "." + mappedProperty.getName()); //$NON-NLS-1$ //$NON-NLS-2$
    }

    if (mappedProperty.isBackRef()) {
        return mappedProperty.getSetter(mappedEntity.getMappedClass());
    }

    final CDOPropertySetter setter;
    if (mappedProperty == mappedEntity.getIdentifierProperty()) {
        setIdentifierTypeAsAnnotation(mappedProperty);
        setter = new CDOIDPropertySetter(this, mappedProperty.getName());
    } else if (mappedProperty.getMetaAttribute("version") != null) {
        setter = new CDOVersionPropertySetter(this, mappedProperty.getName());
    } else if (mappedProperty.getName().compareTo(CDOHibernateConstants.RESOURCE_PROPERTY) == 0) {
        setter = new CDOResourceIDSetter(this, mappedProperty.getName());
    } else if (mappedProperty.getName().compareTo(CDOHibernateConstants.CONTAINER_PROPERTY) == 0) {
        setter = new CDOContainerSetter(this, mappedProperty.getName());
    } else if (mappedProperty.getName().compareTo(CDOHibernateConstants.COMMITTIMESTAMP_PROPERTY) == 0) {
        setter = new CDOBranchTimeStampSetter(this, mappedProperty.getName());
    } else {
        EStructuralFeature feature = getEClass().getEStructuralFeature(mappedProperty.getName());
        if (feature instanceof EReference && feature.isMany()
                && HibernateUtil.getInstance().isCDOResourceContents(feature)) {
            setter = new CDOManyAttributeSetter(this, mappedProperty.getName());
        } else if (feature instanceof EReference && feature.isMany()) {
            setter = new CDOManyReferenceSetter(this, mappedProperty.getName());
        } else if (feature instanceof EAttribute && feature.isMany()) {
            setter = new CDOManyAttributeSetter(this, mappedProperty.getName());
        } else

        if (feature instanceof EReference) {
            setter = new CDOReferenceSetter(this, mappedProperty.getName());
        } else {
            setter = new CDOPropertySetter(this, mappedProperty.getName());
        }
    }

    HibernateStore hbStore = HibernateStore.getCurrentHibernateStore();
    setter.setPersistenceOptions(hbStore.getCDODataStore().getPersistenceOptions());
    return setter;
}

From source file:org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.FeatureMapEntryTuplizer.java

License:Open Source License

@Override
protected Getter buildGetter(Component component, Property prop) {
    return getPropertyAccessor(prop, component).getGetter(component.getComponentClass(), prop.getName());
}

From source file:org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.FeatureMapEntryTuplizer.java

License:Open Source License

@Override
protected Setter buildSetter(Component component, Property prop) {
    return getPropertyAccessor(prop, component).getSetter(component.getComponentClass(), prop.getName());
}

From source file:org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.FeatureMapEntryTuplizer.java

License:Open Source License

protected PropertyAccessor getPropertyAccessor(Property mappedProperty, Component component) {
    if (mappedProperty.getName().compareToIgnoreCase(CDOHibernateConstants.FEATUREMAP_PROPERTY_FEATURE) == 0) {
        return new FeatureMapEntryFeatureURIPropertyHandler();
    } else if (mappedProperty.getName()
            .compareToIgnoreCase(CDOHibernateConstants.FEATUREMAP_PROPERTY_COMMENT) == 0) {
        final FeatureMapEntryPropertyHandler propertyHandler = new FeatureMapEntryPropertyHandler();
        propertyHandler.setPropertyName(COMMENT.getName());
        return propertyHandler;
    } else if (mappedProperty.getName()
            .compareToIgnoreCase(CDOHibernateConstants.FEATUREMAP_PROPERTY_CDATA) == 0) {
        final FeatureMapEntryPropertyHandler propertyHandler = new FeatureMapEntryPropertyHandler();
        propertyHandler.setPropertyName(CDATA.getName());
        return propertyHandler;
    } else if (mappedProperty.getName()
            .compareToIgnoreCase(CDOHibernateConstants.FEATUREMAP_PROPERTY_TEXT) == 0) {
        final FeatureMapEntryPropertyHandler propertyHandler = new FeatureMapEntryPropertyHandler();
        propertyHandler.setPropertyName(TEXT.getName());
        return propertyHandler;
    } else if (mappedProperty.getName().endsWith(CDOHibernateConstants.FEATUREMAP_PROPERTY_ANY_PRIMITIVE)) {
        final WildCardAttributePropertyHandler propertyHandler = new WildCardAttributePropertyHandler();
        final int index = mappedProperty.getName().lastIndexOf(CDOHibernateConstants.PROPERTY_SEPARATOR);
        final String propName = mappedProperty.getName().substring(0, index);
        propertyHandler.setPropertyName(propName);
        return propertyHandler;
    } else if (mappedProperty.getName().endsWith(CDOHibernateConstants.FEATUREMAP_PROPERTY_ANY_REFERENCE)) {
        final FeatureMapEntryPropertyHandler propertyHandler = new FeatureMapEntryPropertyHandler();
        final int index = mappedProperty.getName().lastIndexOf(CDOHibernateConstants.PROPERTY_SEPARATOR);
        final String propName = mappedProperty.getName().substring(0, index);
        propertyHandler.setPropertyName(propName);
        return propertyHandler;
    }//from   w  ww  .  j  av  a 2 s . c  o m

    final FeatureMapEntryPropertyHandler propertyHandler = new FeatureMapEntryPropertyHandler();
    propertyHandler.setPropertyName(mappedProperty.getName());
    return propertyHandler;
}

From source file:org.eclipse.emf.teneo.hibernate.HbDataStore.java

License:Open Source License

/**
 * Extra lazy mapping for lists needs a real property for the list index and
 * a real inverse for the other side as well.
 * //from  w ww  .ja v a  2  s . c  om
 * This method iterates over all associations and adds an inverse for the
 * list and set mappings.
 */
protected void addExtraLazyInverseProperties() {
    final Map<String, PersistentClass> persistentClasses = new HashMap<String, PersistentClass>();
    for (Iterator<?> pcs = getClassMappings(); pcs.hasNext();) {
        final PersistentClass pc = (PersistentClass) pcs.next();
        if (isClassOrSuperClassEAVMapped(pc)) {
            continue;
        }
        persistentClasses.put(pc.getEntityName(), pc);
    }
    for (Iterator<?> pcs = getClassMappings(); pcs.hasNext();) {
        final PersistentClass pc = (PersistentClass) pcs.next();

        // copy to prevent concurrent modification
        final Iterator<?> propIt = pc.getPropertyIterator();
        final List<Property> props = new ArrayList<Property>();
        while (propIt.hasNext()) {
            final Property prop = (Property) propIt.next();
            props.add(prop);
        }

        for (Property prop : props) {
            EClass eClass = null;
            if (pc.getMetaAttribute(HbMapperConstants.FEATUREMAP_META) == null) {
                if (pc.getEntityName() != null) {
                    eClass = getEntityNameStrategy().toEClass(pc.getEntityName());
                } else {
                    eClass = EModelResolver.instance().getEClass(pc.getMappedClass());
                }
            }

            final EStructuralFeature ef = eClass == null ? null
                    : StoreUtil.getEStructuralFeature(eClass, prop.getName());
            if (ef != null && ef instanceof EReference && prop.getValue() instanceof Collection) {
                final Collection collection = (Collection) prop.getValue();
                final EReference eReference = (EReference) ef;

                // only work for extra lazy
                if (!collection.isExtraLazy()) {
                    continue;
                }

                final Value elementValue = collection.getElement();
                final PersistentClass elementPC;
                if (elementValue instanceof OneToMany) {
                    final OneToMany oneToMany = (OneToMany) elementValue;
                    elementPC = oneToMany.getAssociatedClass();
                } else if (elementValue instanceof ManyToOne) {
                    final ManyToOne mto = (ManyToOne) elementValue;
                    elementPC = persistentClasses.get(mto.getReferencedEntityName());
                } else {
                    continue;
                }

                if (isClassOrSuperClassEAVMapped(elementPC)) {
                    continue;
                }

                collection.setInverse(true);

                // and add an eopposite
                if (eReference.getEOpposite() == null) {

                    final Table collectionTable = collection.getCollectionTable();

                    if (isClassOrSuperClassEAVMapped(elementPC)) {
                        continue;
                    }

                    final Property inverseRefProperty = new Property();
                    inverseRefProperty.setName(StoreUtil.getExtraLazyInversePropertyName(ef));
                    final Map<Object, Object> metas = new HashMap<Object, Object>();
                    final MetaAttribute metaAttribute = new MetaAttribute(
                            HbConstants.SYNTHETIC_PROPERTY_INDICATOR);
                    metaAttribute.addValue("true");
                    metas.put(HbConstants.SYNTHETIC_PROPERTY_INDICATOR, metaAttribute);
                    inverseRefProperty.setMetaAttributes(metas);
                    inverseRefProperty.setNodeName(inverseRefProperty.getName());
                    inverseRefProperty.setPropertyAccessorName(SyntheticPropertyHandler.class.getName());
                    inverseRefProperty.setLazy(false);

                    final ManyToOne mto = new ManyToOne(getMappings(), collectionTable);
                    mto.setReferencedEntityName(pc.getEntityName());
                    mto.setLazy(false);
                    mto.setFetchMode(FetchMode.SELECT);

                    inverseRefProperty.setValue(mto);
                    final Iterator<?> it = collection.getKey().getColumnIterator();
                    while (it.hasNext()) {
                        final Column originalColumn = (Column) it.next();
                        // final Column newColumn = new
                        // Column(originalColumn.getName());
                        mto.addColumn(originalColumn);
                    }
                    mto.createForeignKey();

                    // now determine if a join should be created
                    if (collectionTable.getName().equalsIgnoreCase(elementPC.getTable().getName())) {
                        elementPC.addProperty(inverseRefProperty);
                    } else {
                        // create a join
                        final Join join = new Join();
                        join.setPersistentClass(elementPC);
                        join.setTable(collectionTable);
                        join.addProperty(inverseRefProperty);

                        final ManyToOne keyValue = new ManyToOne(getMappings(), collectionTable);
                        join.setKey(keyValue);
                        @SuppressWarnings("unchecked")
                        final Iterator<Column> keyColumns = collection.getElement().getColumnIterator();
                        while (keyColumns.hasNext()) {
                            keyValue.addColumn(keyColumns.next());
                        }
                        keyValue.setReferencedEntityName(elementPC.getEntityName());
                        keyValue.setTable(collectionTable);
                        keyValue.createForeignKey();

                        elementPC.addJoin(join);
                    }
                }

                // add an opposite index
                if (collection.isIndexed() && !collection.isMap()) {

                    Table collectionTable = collection.getCollectionTable();

                    IndexedCollection indexedCollection = (IndexedCollection) collection;

                    final Column column = (Column) indexedCollection.getIndex().getColumnIterator().next();

                    final Property indexProperty = new Property();
                    indexProperty.setName(StoreUtil.getExtraLazyInverseIndexPropertyName(ef));
                    final Map<Object, Object> metas = new HashMap<Object, Object>();
                    final MetaAttribute metaAttribute = new MetaAttribute(
                            HbConstants.SYNTHETIC_PROPERTY_INDICATOR);
                    metaAttribute.addValue("true");
                    metas.put(HbConstants.SYNTHETIC_PROPERTY_INDICATOR, metaAttribute);
                    indexProperty.setMetaAttributes(metas);
                    indexProperty.setNodeName(indexProperty.getName());
                    indexProperty.setPropertyAccessorName(SyntheticPropertyHandler.class.getName());
                    // always make this nullable, nullability is controlled
                    // by the main property
                    indexProperty.setOptional(true);

                    Join join = null;
                    @SuppressWarnings("unchecked")
                    final Iterator<Join> it = (Iterator<Join>) elementPC.getJoinIterator();
                    while (it.hasNext()) {
                        final Join foundJoin = it.next();
                        if (foundJoin.getTable().getName().equalsIgnoreCase(collectionTable.getName())) {
                            join = foundJoin;
                            collectionTable = join.getTable();
                            break;
                        }
                    }

                    final SimpleValue sv = new SimpleValue(getMappings(),
                            indexedCollection.getIndex().getTable());
                    sv.setTypeName("integer");
                    // final Column svColumn = new Column(column.getName());
                    sv.addColumn(column); // checkColumnExists(collectionTable,
                    // svColumn));
                    indexProperty.setValue(sv);
                    if (join != null) {
                        join.addProperty(indexProperty);
                    } else {
                        elementPC.addProperty(indexProperty);
                    }
                }
            }
        }
    }

}

From source file:org.eclipse.emf.teneo.hibernate.HbDataStore.java

License:Open Source License

/** Sets the tuplizer */
protected void setTuplizer() {
    for (Iterator<?> pcs = getClassMappings(); pcs.hasNext();) {
        final PersistentClass pc = (PersistentClass) pcs.next();
        if (pc.getMetaAttribute(HbMapperConstants.FEATUREMAP_META) != null) { // featuremap
            // entry
            pc.addTuplizer(EntityMode.MAP,
                    getHbContext().getFeatureMapEntryTuplizer(getHibernateConfiguration()).getName());
        } else if (pc.getMetaAttribute(HbMapperConstants.ECLASS_NAME_META) != null) {
            // only the pc's with this meta should get a tuplizer

            pc.addTuplizer(EntityMode.MAP,
                    getHbContext().getEMFTuplizerClass(getHibernateConfiguration()).getName());
            pc.addTuplizer(EntityMode.POJO,
                    getHbContext().getEMFTuplizerClass(getHibernateConfiguration()).getName());
        } else if (pc.getMetaAttribute(HbMapperConstants.ECLASS_NAME_META) == null) {
            // don't change these pc's any further, these are not eclasses
            continue;
        }/* ww  w .j  a  v  a2 s.  c  o m*/

        // also set the tuplizer for the components, and register for the
        // component

        // Build a list of all properties.
        java.util.List<Property> properties = new ArrayList<Property>();
        final Property identifierProperty = pc.getIdentifierProperty();
        if (identifierProperty != null) {
            properties.add(identifierProperty);
        }
        for (Iterator<?> it = pc.getPropertyIterator(); it.hasNext();) {
            properties.add((Property) it.next());
        }

        // Now set component tuplizers where necessary.
        for (Object name2 : properties) {
            Property prop = (Property) name2;
            if (prop.getName().compareTo("_identifierMapper") == 0) {
                continue; // ignore this one
            }
            final Value value = prop.getValue();
            if (value instanceof Component) {
                setComponentTuplizer((Component) value, getHibernateConfiguration());
            } else if (value instanceof Collection && ((Collection) value).getElement() instanceof Component) {
                setComponentTuplizer((Component) ((Collection) value).getElement(),
                        getHibernateConfiguration());
            }
        }
    }
}