protected void processEmbeddedMember(List<AbstractMemberMetaData> mmds, AbstractClassMetaData embCmd, ClassLoaderResolver clr, EmbeddedMetaData embmd, boolean ownerNested)
    {
        TypeManager typeMgr = storeMgr.getNucleusContext().getTypeManager();
        MetaDataManager mmgr = storeMgr.getMetaDataManager();
        NamingFactory namingFactory = storeMgr.getNamingFactory();
        AbstractMemberMetaData lastMmd = mmds.get(mmds.size()-1);
        // Go through all members of the embedded type
        int[] memberPositions = embCmd.getAllMemberPositions();
        for (int i=0;i<memberPositions.length;i++)
        {
            AbstractMemberMetaData mmd = embCmd.getMetaDataForManagedMemberAtAbsolutePosition(memberPositions[i]);
            if (mmd.getPersistenceModifier() != FieldPersistenceModifier.PERSISTENT)
            {
                // Don't need column if not persistent
                continue;
            }
            if (mmds.size() == 1 && embmd != null && embmd.getOwnerMember() != null && embmd.getOwnerMember().equals(mmd.getName()))
            {
                // Special case of this being a link back to the owner. TODO Repeat this for nested and their owners
                continue;
            }
            AbstractMemberMetaData embmdMmd = null;
            if (embmd != null)
            {
                AbstractMemberMetaData[] embmdMmds = embmd.getMemberMetaData();
                if (embmdMmds != null)
                {
                    for (AbstractMemberMetaData thisMmd : embmdMmds)
                    {
                        if (thisMmd.getName().equals(mmd.getName()))
                        {
                            embmdMmd = thisMmd;
                            break;
                        }
                    }
                }
            }
            RelationType relationType = mmd.getRelationType(clr);
            if (relationType != RelationType.NONE && MetaDataUtils.getInstance().isMemberEmbedded(mmgr, clr, mmd, relationType, lastMmd))
            {
                if (RelationType.isRelationSingleValued(relationType))
                {
                    // Nested embedded PC, so recurse
                    boolean nested = false;
                    if (storeMgr.getSupportedOptions().contains(StoreManager.OPTION_ORM_EMBEDDED_PC_NESTED))
                    {
                        nested = !storeMgr.getNucleusContext().getConfiguration().getBooleanProperty(PropertyNames.PROPERTY_METADATA_EMBEDDED_PC_FLAT);
                        String nestedStr = mmd.getValueForExtension("nested");
                        if (nestedStr != null && nestedStr.equalsIgnoreCase("" + !nested))
                        {
                            nested = !nested;
                        }
                    }
                    List<AbstractMemberMetaData> embMmds = new ArrayList<AbstractMemberMetaData>(mmds);
                    embMmds.add(mmd);
                    if (nested)
                    {
                        // Embedded object stored as nested under this in the owner table (where the datastore supports that)
                        // Add column for the owner of the embedded object, typically for the column name only
                        ColumnMetaData[] colmds = mmd.getColumnMetaData();
                        String colName = namingFactory.getColumnName(embMmds, 0);
                        ColumnImpl col = addEmbeddedColumn(colName, null);
                        col.setNested(true);
                        if (embmdMmd != null && embmdMmd.getColumnMetaData() != null && embmdMmd.getColumnMetaData().length == 1 && embmdMmd.getColumnMetaData()[0].getPosition() != null)
                        {
                            col.setPosition(embmdMmd.getColumnMetaData()[0].getPosition());
                        }
                        else if (colmds != null && colmds.length == 1 && colmds[0].getPosition() != null)
                        {
                            col.setPosition(colmds[0].getPosition());
                        }
                        if (embmdMmd != null && embmdMmd.getColumnMetaData() != null && embmdMmd.getColumnMetaData().length == 1 && embmdMmd.getColumnMetaData()[0].getJdbcType() != null)
                        {
                            col.setJdbcType(embmdMmd.getColumnMetaData()[0].getJdbcType());
                        }
                        else if (colmds != null && colmds.length == 1 && colmds[0].getJdbcType() != null)
                        {
                            col.setJdbcType(colmds[0].getJdbcType());
                        }
                        MemberColumnMapping mapping = new MemberColumnMappingImpl(mmd, col);
                        col.setMemberColumnMapping(mapping);
                        if (schemaVerifier != null)
                        {
                            schemaVerifier.attributeEmbeddedMember(mapping, embMmds);
                        }
                        mappingByEmbeddedMember.put(getEmbeddedMemberNavigatedPath(embMmds), mapping);
                        // TODO Create mapping for the related info under the above column
                    }
                    // Recurse through the embedded member
                    processEmbeddedMember(embMmds, mmgr.getMetaDataForClass(mmd.getType(), clr), clr, embmdMmd != null ? embmdMmd.getEmbeddedMetaData() : null, nested);
                }
                else
                {
                    if (mmd.hasCollection())
                    {
                        // Nested embedded collection, so recurse
                        if (storeMgr.getSupportedOptions().contains(StoreManager.OPTION_ORM_EMBEDDED_COLLECTION_NESTED))
                        {
                            List<AbstractMemberMetaData> embMmds = new ArrayList<AbstractMemberMetaData>(mmds);
                            embMmds.add(mmd);
                            // Add column for the collection (since the store needs a name to reference it by)
                            ColumnMetaData[] colmds = mmd.getColumnMetaData();
                            String colName = namingFactory.getColumnName(embMmds, 0);
                            ColumnImpl col = addEmbeddedColumn(colName, null);
                            col.setNested(true);
                            if (embmdMmd != null && embmdMmd.getColumnMetaData() != null && embmdMmd.getColumnMetaData().length == 1 && embmdMmd.getColumnMetaData()[0].getPosition() != null)
                            {
                                col.setPosition(embmdMmd.getColumnMetaData()[0].getPosition());
                            }
                            else if (colmds != null && colmds.length == 1 && colmds[0].getPosition() != null)
                            {
                                col.setPosition(colmds[0].getPosition());
                            }
                            if (embmdMmd != null && embmdMmd.getColumnMetaData() != null && embmdMmd.getColumnMetaData().length == 1 && embmdMmd.getColumnMetaData()[0].getJdbcType() != null)
                            {
                                col.setJdbcType(embmdMmd.getColumnMetaData()[0].getJdbcType());
                            }
                            else if (colmds != null && colmds.length == 1 && colmds[0].getJdbcType() != null)
                            {
                                col.setJdbcType(colmds[0].getJdbcType());
                            }
                            MemberColumnMapping mapping = new MemberColumnMappingImpl(mmd, col);
                            col.setMemberColumnMapping(mapping);
                            if (schemaVerifier != null)
                            {
                                schemaVerifier.attributeEmbeddedMember(mapping, embMmds);
                            }
                            mappingByEmbeddedMember.put(getEmbeddedMemberNavigatedPath(embMmds), mapping);
                            // TODO Create mapping for the related info under the above column
                            // Recurse through the embedded collection element
                            processEmbeddedMember(embMmds, mmgr.getMetaDataForClass(mmd.getCollection().getElementType(), clr), clr, embmdMmd != null ? embmdMmd.getEmbeddedMetaData() : null, true);
                        }
                        else
                        {
                            NucleusLogger.DATASTORE_SCHEMA.warn("Member " + mmd.getFullFieldName() + " is a (nested) embedded collection. Not supported for this datastore so ignoring");
                            continue;
                        }
                    }
                    else if (mmd.hasMap())
                    {
                        // Nested embedded map, so recurse
                        if (storeMgr.getSupportedOptions().contains(StoreManager.OPTION_ORM_EMBEDDED_MAP_NESTED))
                        {
                            // TODO Support nested embedded map key/value
                            NucleusLogger.DATASTORE_SCHEMA.warn("Member " + mmd.getFullFieldName() + " is a (nested) embedded map. Not yet supported so ignoring");
                        }
                        else
                        {
                            NucleusLogger.DATASTORE_SCHEMA.warn("Member " + mmd.getFullFieldName() + " is a (nested) embedded map. Not supported for this datastore so ignoring");
                            continue;
                        }
                    }
                    else if (mmd.hasArray())
                    {
                        // Nested embedded array, so recurse
                        if (storeMgr.getSupportedOptions().contains(StoreManager.OPTION_ORM_EMBEDDED_ARRAY_NESTED))
                        {
                            List<AbstractMemberMetaData> embMmds = new ArrayList<AbstractMemberMetaData>(mmds);
                            embMmds.add(mmd);
                            // Add column for the array (since the store needs a name to reference it by) TODO Extract this block out and reuse it
                            ColumnMetaData[] colmds = mmd.getColumnMetaData();
                            String colName = namingFactory.getColumnName(embMmds, 0);
                            ColumnImpl col = addEmbeddedColumn(colName, null);
                            col.setNested(true);
                            if (embmdMmd != null && embmdMmd.getColumnMetaData() != null && embmdMmd.getColumnMetaData().length == 1 && embmdMmd.getColumnMetaData()[0].getPosition() != null)
                            {
                                col.setPosition(embmdMmd.getColumnMetaData()[0].getPosition());
                            }
                            else if (colmds != null && colmds.length == 1 && colmds[0].getPosition() != null)
                            {
                                col.setPosition(colmds[0].getPosition());
                            }
                            if (embmdMmd != null && embmdMmd.getColumnMetaData() != null && embmdMmd.getColumnMetaData().length == 1 && embmdMmd.getColumnMetaData()[0].getJdbcType() != null)
                            {
                                col.setJdbcType(embmdMmd.getColumnMetaData()[0].getJdbcType());
                            }
                            else if (colmds != null && colmds.length == 1 && colmds[0].getJdbcType() != null)
                            {
                                col.setJdbcType(colmds[0].getJdbcType());
                            }
                            MemberColumnMapping mapping = new MemberColumnMappingImpl(mmd, col);
                            col.setMemberColumnMapping(mapping);
                            if (schemaVerifier != null)
                            {
                                schemaVerifier.attributeEmbeddedMember(mapping, embMmds);
                            }
                            mappingByEmbeddedMember.put(getEmbeddedMemberNavigatedPath(embMmds), mapping);
                            // TODO Create mapping for the related info under the above column
                            // Recurse through the embedded array element
                            processEmbeddedMember(embMmds, mmgr.getMetaDataForClass(mmd.getArray().getElementType(), clr), clr, embmdMmd != null ? embmdMmd.getEmbeddedMetaData() : null, true);
                        }
                        else
                        {
                            NucleusLogger.DATASTORE_SCHEMA.warn("Member " + mmd.getFullFieldName() + " is a (nested) embedded array. Not supported for this datastore so ignoring");
                            continue;
                        }
                    }
                }
            }
            else
            {
                List<AbstractMemberMetaData> embMmds = new ArrayList<AbstractMemberMetaData>(mmds);
                embMmds.add(mmd);
                ColumnMetaData[] colmds = mmd.getColumnMetaData();
                if (relationType != RelationType.NONE)
                {
                    // 1-1/N-1 stored as single column with persistable-id
                    // 1-N/M-N stored as single column with collection<persistable-id>
                    // Create column for basic type
                    String colName = namingFactory.getColumnName(embMmds, 0);
                    ColumnImpl col = addEmbeddedColumn(colName, null);
                    col.setNested(ownerNested);
                    if (embmdMmd != null && embmdMmd.getColumnMetaData() != null && embmdMmd.getColumnMetaData().length == 1 && embmdMmd.getColumnMetaData()[0].getPosition() != null)
                    {
                        col.setPosition(embmdMmd.getColumnMetaData()[0].getPosition());
                    }
                    else if (colmds != null && colmds.length == 1 && colmds[0].getPosition() != null)
                    {
                        col.setPosition(colmds[0].getPosition());
                    }
                    if (embmdMmd != null && embmdMmd.getColumnMetaData() != null && embmdMmd.getColumnMetaData().length == 1 && embmdMmd.getColumnMetaData()[0].getJdbcType() != null)
                    {
                        col.setJdbcType(embmdMmd.getColumnMetaData()[0].getJdbcType());
                    }
                    else if (colmds != null && colmds.length == 1 && colmds[0].getJdbcType() != null)
                    {
                        col.setJdbcType(colmds[0].getJdbcType());
                    }
                    MemberColumnMapping mapping = new MemberColumnMappingImpl(mmd, col);
                    col.setMemberColumnMapping(mapping);
                    if (schemaVerifier != null)
                    {
                        schemaVerifier.attributeEmbeddedMember(mapping, embMmds);
                    }
                    mappingByEmbeddedMember.put(getEmbeddedMemberNavigatedPath(embMmds), mapping);
                }
                else
                {
                    TypeConverter typeConv = getTypeConverterForMember(mmd, colmds, typeMgr); // TODO Pass in embedded colmds if they have jdbcType info?
                    if (typeConv != null)
                    {
                        // Create column(s) for this type using a TypeConverter
                        if (typeConv instanceof MultiColumnConverter)
                        {
                            Class[] colJavaTypes = ((MultiColumnConverter)typeConv).getDatastoreColumnTypes();
                            Column[] cols = new Column[colJavaTypes.length];
                            for (int j=0;j<colJavaTypes.length;j++)
                            {
                                String colName = namingFactory.getColumnName(embMmds, j);
                                ColumnImpl col = addEmbeddedColumn(colName, typeConv);
                                col.setNested(ownerNested);
                                if (embmdMmd != null && embmdMmd.getColumnMetaData() != null && embmdMmd.getColumnMetaData().length == colJavaTypes.length && embmdMmd.getColumnMetaData()[j].getPosition() != null)
                                {
                                    col.setPosition(embmdMmd.getColumnMetaData()[j].getPosition());
                                }
                                else if (colmds != null && colmds.length == colJavaTypes.length && colmds[j].getPosition() != null)
                                {
                                    col.setPosition(colmds[j].getPosition());
                                }
                                if (embmdMmd != null && embmdMmd.getColumnMetaData() != null && embmdMmd.getColumnMetaData().length == colJavaTypes.length && embmdMmd.getColumnMetaData()[j].getJdbcType() != null)
                                {
                                    col.setJdbcType(embmdMmd.getColumnMetaData()[j].getJdbcType());
                                }
                                else if (colmds != null && colmds.length == colJavaTypes.length && colmds[j].getJdbcType() != null)
                                {
                                    col.setJdbcType(colmds[j].getJdbcType());
                                }
                                cols[j] = col;
                            }
                            MemberColumnMapping mapping = new MemberColumnMappingImpl(mmd, cols, typeConv);
                            for (int j=0;j<colJavaTypes.length;j++)
                            {
                                ((ColumnImpl)cols[j]).setMemberColumnMapping(mapping);
                            }
                            if (schemaVerifier != null)
                            {
                                schemaVerifier.attributeEmbeddedMember(mapping, embMmds);
                            }
                            mappingByEmbeddedMember.put(getEmbeddedMemberNavigatedPath(embMmds), mapping);
                        }
                        else
                        {
                            String colName = namingFactory.getColumnName(embMmds, 0);
                            ColumnImpl col = addEmbeddedColumn(colName, typeConv);
                            col.setNested(ownerNested);
                            if (embmdMmd != null && embmdMmd.getColumnMetaData() != null && embmdMmd.getColumnMetaData().length == 1 && embmdMmd.getColumnMetaData()[0].getPosition() != null)
                            {
                                col.setPosition(embmdMmd.getColumnMetaData()[0].getPosition());
                            }
                            else if (colmds != null && colmds.length == 1 && colmds[0].getPosition() != null)
                            {
                                col.setPosition(colmds[0].getPosition());
                            }
                            if (embmdMmd != null && embmdMmd.getColumnMetaData() != null && embmdMmd.getColumnMetaData().length == 1 && embmdMmd.getColumnMetaData()[0].getJdbcType() != null)
                            {
                                col.setJdbcType(embmdMmd.getColumnMetaData()[0].getJdbcType());
                            }
                            else if (colmds != null && colmds.length == 1 && colmds[0].getJdbcType() != null)
                            {
                                col.setJdbcType(colmds[0].getJdbcType());
                            }
                            MemberColumnMapping mapping = new MemberColumnMappingImpl(mmd, col);
                            col.setMemberColumnMapping(mapping);
                            mapping.setTypeConverter(typeConv);
                            if (schemaVerifier != null)
                            {
                                schemaVerifier.attributeEmbeddedMember(mapping, embMmds);
                            }
                            mappingByEmbeddedMember.put(getEmbeddedMemberNavigatedPath(embMmds), mapping);
                        }
                    }
                    else
                    {
                        // Create column for basic type
                        String colName = namingFactory.getColumnName(embMmds, 0);
                        ColumnImpl col = addEmbeddedColumn(colName, null);
                        col.setNested(ownerNested);
                        AbstractMemberMetaData theMmd = embMmds.get(0);
                        if (theMmd.isPrimaryKey())
                        {
                            col.setPrimaryKey();
                        }
                        if (embmdMmd != null && embmdMmd.getColumnMetaData() != null && embmdMmd.getColumnMetaData().length == 1 && embmdMmd.getColumnMetaData()[0].getPosition() != null)
                        {
                            col.setPosition(embmdMmd.getColumnMetaData()[0].getPosition());
                        }
                        else if (colmds != null && colmds.length == 1 && colmds[0].getPosition() != null)
                        {
                            col.setPosition(colmds[0].getPosition());
                        }
                        if (embmdMmd != null && embmdMmd.getColumnMetaData() != null && embmdMmd.getColumnMetaData().length == 1 && embmdMmd.getColumnMetaData()[0].getJdbcType() != null)
                        {
                            col.setJdbcType(embmdMmd.getColumnMetaData()[0].getJdbcType());
                        }
                        else if (colmds != null && colmds.length == 1 && colmds[0].getJdbcType() != null)
                        {
                            col.setJdbcType(colmds[0].getJdbcType());
                        }
                        MemberColumnMapping mapping = new MemberColumnMappingImpl(mmd, col);
                        col.setMemberColumnMapping(mapping);
                        if (schemaVerifier != null)
                        {
                            schemaVerifier.attributeEmbeddedMember(mapping, embMmds);
                        }
                        mappingByEmbeddedMember.put(getEmbeddedMemberNavigatedPath(embMmds), mapping);
                    }
                }
            }
        }
    }
protected void processEmbeddedMember(List<AbstractMemberMetaData> mmds, AbstractClassMetaData embCmd, ClassLoaderResolver clr, EmbeddedMetaData embmd, boolean ownerNested)
    {
        TypeManager typeMgr = storeMgr.getNucleusContext().getTypeManager();
        MetaDataManager mmgr = storeMgr.getMetaDataManager();
        NamingFactory namingFactory = storeMgr.getNamingFactory();
        AbstractMemberMetaData lastMmd = mmds.get(mmds.size()-1);
       
        int[] memberPositions = embCmd.getAllMemberPositions();
        for (int i=0;i<memberPositions.length;i++)
        {
            AbstractMemberMetaData mmd = embCmd.getMetaDataForManagedMemberAtAbsolutePosition(memberPositions[i]);
            if (mmd.getPersistenceModifier() != FieldPersistenceModifier.PERSISTENT)
            {
               
                continue;
            }
            if (mmds.size() == 1 && embmd != null && embmd.getOwnerMember() != null && embmd.getOwnerMember().equals(mmd.getName()))
            {
               
                continue;
            }
            AbstractMemberMetaData embmdMmd = null;
            if (embmd != null)
            {
                AbstractMemberMetaData[] embmdMmds = embmd.getMemberMetaData();
                if (embmdMmds != null)
                {
                    for (AbstractMemberMetaData thisMmd : embmdMmds)
                    {
                        if (thisMmd.getName().equals(mmd.getName()))
                        {
                            embmdMmd = thisMmd;
                            break;
                        }
                    }
                }
            }
            RelationType relationType = mmd.getRelationType(clr);
            if (relationType != RelationType.NONE && MetaDataUtils.getInstance().isMemberEmbedded(mmgr, clr, mmd, relationType, lastMmd))
            {
                if (RelationType.isRelationSingleValued(relationType))
                {
                   
                    boolean nested = false;
                    if (storeMgr.getSupportedOptions().contains(StoreManager.OPTION_ORM_EMBEDDED_PC_NESTED))
                    {
                        nested = !storeMgr.getNucleusContext().getConfiguration().getBooleanProperty(PropertyNames.PROPERTY_METADATA_EMBEDDED_PC_FLAT);
                        String nestedStr = mmd.getValueForExtension("nested");
                        if (nestedStr != null && nestedStr.equalsIgnoreCase("" + !nested))
                        {
                            nested = !nested;
                        }
                    }
                    List<AbstractMemberMetaData> embMmds = new ArrayList<AbstractMemberMetaData>(mmds);
                    embMmds.add(mmd);
                    if (nested)
                    {
                       
                       
                        ColumnMetaData[] colmds = mmd.getColumnMetaData();
                        String colName = namingFactory.getColumnName(embMmds, 0);
                        ColumnImpl col = addEmbeddedColumn(colName, null);
                        col.setNested(true);
                        if (embmdMmd != null && embmdMmd.getColumnMetaData() != null && embmdMmd.getColumnMetaData().length == 1 && embmdMmd.getColumnMetaData()[0].getPosition() != null)
                        {
                            col.setPosition(embmdMmd.getColumnMetaData()[0].getPosition());
                        }
                        else if (colmds != null && colmds.length == 1 && colmds[0].getPosition() != null)
                        {
                            col.setPosition(colmds[0].getPosition());
                        }
                        if (embmdMmd != null && embmdMmd.getColumnMetaData() != null && embmdMmd.getColumnMetaData().length == 1 && embmdMmd.getColumnMetaData()[0].getJdbcType() != null)
                        {
                            col.setJdbcType(embmdMmd.getColumnMetaData()[0].getJdbcType());
                        }
                        else if (colmds != null && colmds.length == 1 && colmds[0].getJdbcType() != null)
                        {
                            col.setJdbcType(colmds[0].getJdbcType());
                        }
                        MemberColumnMapping mapping = new MemberColumnMappingImpl(mmd, col);
                        col.setMemberColumnMapping(mapping);
                        if (schemaVerifier != null)
                        {
                            schemaVerifier.attributeEmbeddedMember(mapping, embMmds);
                        }
                        mappingByEmbeddedMember.put(getEmbeddedMemberNavigatedPath(embMmds), mapping);
                       
                    }
                   
                    processEmbeddedMember(embMmds, mmgr.getMetaDataForClass(mmd.getType(), clr), clr, embmdMmd != null ? embmdMmd.getEmbeddedMetaData() : null, nested);
                }
                else
                {
                    if (mmd.hasCollection())
                    {
                       
                        if (storeMgr.getSupportedOptions().contains(StoreManager.OPTION_ORM_EMBEDDED_COLLECTION_NESTED))
                        {
                            List<AbstractMemberMetaData> embMmds = new ArrayList<AbstractMemberMetaData>(mmds);
                            embMmds.add(mmd);
                           
                            ColumnMetaData[] colmds = mmd.getColumnMetaData();
                            String colName = namingFactory.getColumnName(embMmds, 0);
                            ColumnImpl col = addEmbeddedColumn(colName, null);
                            col.setNested(true);
                            if (embmdMmd != null && embmdMmd.getColumnMetaData() != null && embmdMmd.getColumnMetaData().length == 1 && embmdMmd.getColumnMetaData()[0].getPosition() != null)
                            {
                                col.setPosition(embmdMmd.getColumnMetaData()[0].getPosition());
                            }
                            else if (colmds != null && colmds.length == 1 && colmds[0].getPosition() != null)
                            {
                                col.setPosition(colmds[0].getPosition());
                            }
                            if (embmdMmd != null && embmdMmd.getColumnMetaData() != null && embmdMmd.getColumnMetaData().length == 1 && embmdMmd.getColumnMetaData()[0].getJdbcType() != null)
                            {
                                col.setJdbcType(embmdMmd.getColumnMetaData()[0].getJdbcType());
                            }
                            else if (colmds != null && colmds.length == 1 && colmds[0].getJdbcType() != null)
                            {
                                col.setJdbcType(colmds[0].getJdbcType());
                            }
                            MemberColumnMapping mapping = new MemberColumnMappingImpl(mmd, col);
                            col.setMemberColumnMapping(mapping);
                            if (schemaVerifier != null)
                            {
                                schemaVerifier.attributeEmbeddedMember(mapping, embMmds);
                            }
                            mappingByEmbeddedMember.put(getEmbeddedMemberNavigatedPath(embMmds), mapping);
                           
                           
                            processEmbeddedMember(embMmds, mmgr.getMetaDataForClass(mmd.getCollection().getElementType(), clr), clr, embmdMmd != null ? embmdMmd.getEmbeddedMetaData() : null, true);
                        }
                        else
                        {
                            NucleusLogger.DATASTORE_SCHEMA.warn("Member " + mmd.getFullFieldName() + " is a (nested) embedded collection. Not supported for this datastore so ignoring");
                            continue;
                        }
                    }
                    else if (mmd.hasMap())
                    {
                       
                        if (storeMgr.getSupportedOptions().contains(StoreManager.OPTION_ORM_EMBEDDED_MAP_NESTED))
                        {
                           
                            NucleusLogger.DATASTORE_SCHEMA.warn("Member " + mmd.getFullFieldName() + " is a (nested) embedded map. Not yet supported so ignoring");
                        }
                        else
                        {
                            NucleusLogger.DATASTORE_SCHEMA.warn("Member " + mmd.getFullFieldName() + " is a (nested) embedded map. Not supported for this datastore so ignoring");
                            continue;
                        }
                    }
                    else if (mmd.hasArray())
                    {
                       
                        if (storeMgr.getSupportedOptions().contains(StoreManager.OPTION_ORM_EMBEDDED_ARRAY_NESTED))
                        {
                            List<AbstractMemberMetaData> embMmds = new ArrayList<AbstractMemberMetaData>(mmds);
                            embMmds.add(mmd);
                           
                            ColumnMetaData[] colmds = mmd.getColumnMetaData();
                            String colName = namingFactory.getColumnName(embMmds, 0);
                            ColumnImpl col = addEmbeddedColumn(colName, null);
                            col.setNested(true);
                            if (embmdMmd != null && embmdMmd.getColumnMetaData() != null && embmdMmd.getColumnMetaData().length == 1 && embmdMmd.getColumnMetaData()[0].getPosition() != null)
                            {
                                col.setPosition(embmdMmd.getColumnMetaData()[0].getPosition());
                            }
                            else if (colmds != null && colmds.length == 1 && colmds[0].getPosition() != null)
                            {
                                col.setPosition(colmds[0].getPosition());
                            }
                            if (embmdMmd != null && embmdMmd.getColumnMetaData() != null && embmdMmd.getColumnMetaData().length == 1 && embmdMmd.getColumnMetaData()[0].getJdbcType() != null)
                            {
                                col.setJdbcType(embmdMmd.getColumnMetaData()[0].getJdbcType());
                            }
                            else if (colmds != null && colmds.length == 1 && colmds[0].getJdbcType() != null)
                            {
                                col.setJdbcType(colmds[0].getJdbcType());
                            }
                            MemberColumnMapping mapping = new MemberColumnMappingImpl(mmd, col);
                            col.setMemberColumnMapping(mapping);
                            if (schemaVerifier != null)
                            {
                                schemaVerifier.attributeEmbeddedMember(mapping, embMmds);
                            }
                            mappingByEmbeddedMember.put(getEmbeddedMemberNavigatedPath(embMmds), mapping);
                           
                           
                            processEmbeddedMember(embMmds, mmgr.getMetaDataForClass(mmd.getArray().getElementType(), clr), clr, embmdMmd != null ? embmdMmd.getEmbeddedMetaData() : null, true);
                        }
                        else
                        {
                            NucleusLogger.DATASTORE_SCHEMA.warn("Member " + mmd.getFullFieldName() + " is a (nested) embedded array. Not supported for this datastore so ignoring");
                            continue;
                        }
                    }
                }
            }
            else
            {
                List<AbstractMemberMetaData> embMmds = new ArrayList<AbstractMemberMetaData>(mmds);
                embMmds.add(mmd);
                ColumnMetaData[] colmds = mmd.getColumnMetaData();
                if (relationType != RelationType.NONE)
                {
                   
                   
                   
                    String colName = namingFactory.getColumnName(embMmds, 0);
                    ColumnImpl col = addEmbeddedColumn(colName, null);
                    col.setNested(ownerNested);
                    if (embmdMmd != null && embmdMmd.getColumnMetaData() != null && embmdMmd.getColumnMetaData().length == 1 && embmdMmd.getColumnMetaData()[0].getPosition() != null)
                    {
                        col.setPosition(embmdMmd.getColumnMetaData()[0].getPosition());
                    }
                    else if (colmds != null && colmds.length == 1 && colmds[0].getPosition() != null)
                    {
                        col.setPosition(colmds[0].getPosition());
                    }
                    if (embmdMmd != null && embmdMmd.getColumnMetaData() != null && embmdMmd.getColumnMetaData().length == 1 && embmdMmd.getColumnMetaData()[0].getJdbcType() != null)
                    {
                        col.setJdbcType(embmdMmd.getColumnMetaData()[0].getJdbcType());
                    }
                    else if (colmds != null && colmds.length == 1 && colmds[0].getJdbcType() != null)
                    {
                        col.setJdbcType(colmds[0].getJdbcType());
                    }
                    MemberColumnMapping mapping = new MemberColumnMappingImpl(mmd, col);
                    col.setMemberColumnMapping(mapping);
                    if (schemaVerifier != null)
                    {
                        schemaVerifier.attributeEmbeddedMember(mapping, embMmds);
                    }
                    mappingByEmbeddedMember.put(getEmbeddedMemberNavigatedPath(embMmds), mapping);
                }
                else
                {
                    TypeConverter typeConv = getTypeConverterForMember(mmd, colmds, typeMgr);
                    if (typeConv != null)
                    {
                       
                        if (typeConv instanceof MultiColumnConverter)
                        {
                            Class[] colJavaTypes = ((MultiColumnConverter)typeConv).getDatastoreColumnTypes();
                            Column[] cols = new Column[colJavaTypes.length];
                            for (int j=0;j<colJavaTypes.length;j++)
                            {
                                String colName = namingFactory.getColumnName(embMmds, j);
                                ColumnImpl col = addEmbeddedColumn(colName, typeConv);
                                col.setNested(ownerNested);
                                if (embmdMmd != null && embmdMmd.getColumnMetaData() != null && embmdMmd.getColumnMetaData().length == colJavaTypes.length && embmdMmd.getColumnMetaData()[j].getPosition() != null)
                                {
                                    col.setPosition(embmdMmd.getColumnMetaData()[j].getPosition());
                                }
                                else if (colmds != null && colmds.length == colJavaTypes.length && colmds[j].getPosition() != null)
                                {
                                    col.setPosition(colmds[j].getPosition());
                                }
                                if (embmdMmd != null && embmdMmd.getColumnMetaData() != null && embmdMmd.getColumnMetaData().length == colJavaTypes.length && embmdMmd.getColumnMetaData()[j].getJdbcType() != null)
                                {
                                    col.setJdbcType(embmdMmd.getColumnMetaData()[j].getJdbcType());
                                }
                                else if (colmds != null && colmds.length == colJavaTypes.length && colmds[j].getJdbcType() != null)
                                {
                                    col.setJdbcType(colmds[j].getJdbcType());
                                }
                                cols[j] = col;
                            }
                            MemberColumnMapping mapping = new MemberColumnMappingImpl(mmd, cols, typeConv);
                            for (int j=0;j<colJavaTypes.length;j++)
                            {
                                ((ColumnImpl)cols[j]).setMemberColumnMapping(mapping);
                            }
                            if (schemaVerifier != null)
                            {
                                schemaVerifier.attributeEmbeddedMember(mapping, embMmds);
                            }
                            mappingByEmbeddedMember.put(getEmbeddedMemberNavigatedPath(embMmds), mapping);
                        }
                        else
                        {
                            String colName = namingFactory.getColumnName(embMmds, 0);
                            ColumnImpl col = addEmbeddedColumn(colName, typeConv);
                            col.setNested(ownerNested);
                            if (embmdMmd != null && embmdMmd.getColumnMetaData() != null && embmdMmd.getColumnMetaData().length == 1 && embmdMmd.getColumnMetaData()[0].getPosition() != null)
                            {
                                col.setPosition(embmdMmd.getColumnMetaData()[0].getPosition());
                            }
                            else if (colmds != null && colmds.length == 1 && colmds[0].getPosition() != null)
                            {
                                col.setPosition(colmds[0].getPosition());
                            }
                            if (embmdMmd != null && embmdMmd.getColumnMetaData() != null && embmdMmd.getColumnMetaData().length == 1 && embmdMmd.getColumnMetaData()[0].getJdbcType() != null)
                            {
                                col.setJdbcType(embmdMmd.getColumnMetaData()[0].getJdbcType());
                            }
                            else if (colmds != null && colmds.length == 1 && colmds[0].getJdbcType() != null)
                            {
                                col.setJdbcType(colmds[0].getJdbcType());
                            }
                            MemberColumnMapping mapping = new MemberColumnMappingImpl(mmd, col);
                            col.setMemberColumnMapping(mapping);
                            mapping.setTypeConverter(typeConv);
                            if (schemaVerifier != null)
                            {
                                schemaVerifier.attributeEmbeddedMember(mapping, embMmds);
                            }
                            mappingByEmbeddedMember.put(getEmbeddedMemberNavigatedPath(embMmds), mapping);
                        }
                    }
                    else
                    {
                       
                        String colName = namingFactory.getColumnName(embMmds, 0);
                        ColumnImpl col = addEmbeddedColumn(colName, null);
                        col.setNested(ownerNested);
                        AbstractMemberMetaData theMmd = embMmds.get(0);
                        if (theMmd.isPrimaryKey())
                        {
                            col.setPrimaryKey();
                        }
                        if (embmdMmd != null && embmdMmd.getColumnMetaData() != null && embmdMmd.getColumnMetaData().length == 1 && embmdMmd.getColumnMetaData()[0].getPosition() != null)
                        {
                            col.setPosition(embmdMmd.getColumnMetaData()[0].getPosition());
                        }
                        else if (colmds != null && colmds.length == 1 && colmds[0].getPosition() != null)
                        {
                            col.setPosition(colmds[0].getPosition());
                        }
                        if (embmdMmd != null && embmdMmd.getColumnMetaData() != null && embmdMmd.getColumnMetaData().length == 1 && embmdMmd.getColumnMetaData()[0].getJdbcType() != null)
                        {
                            col.setJdbcType(embmdMmd.getColumnMetaData()[0].getJdbcType());
                        }
                        else if (colmds != null && colmds.length == 1 && colmds[0].getJdbcType() != null)
                        {
                            col.setJdbcType(colmds[0].getJdbcType());
                        }
                        MemberColumnMapping mapping = new MemberColumnMappingImpl(mmd, col);
                        col.setMemberColumnMapping(mapping);
                        if (schemaVerifier != null)
                        {
                            schemaVerifier.attributeEmbeddedMember(mapping, embMmds);
                        }
                        mappingByEmbeddedMember.put(getEmbeddedMemberNavigatedPath(embMmds), mapping);
                    }
                }
            }
        }
    }
protected void processembeddedmember(list<abstractmembermetadata> mmds, abstractclassmetadata embcmd, classloaderresolver clr, embeddedmetadata embmd, boolean ownernested) { typemanager typemgr = storemgr.getnucleuscontext().gettypemanager(); metadatamanager mmgr = storemgr.getmetadatamanager(); namingfactory namingfactory = storemgr.getnamingfactory(); abstractmembermetadata lastmmd = mmds.get(mmds.size()-1); int[] memberpositions = embcmd.getallmemberpositions(); for (int i=0;i<memberpositions.length;i++) { abstractmembermetadata mmd = embcmd.getmetadataformanagedmemberatabsoluteposition(memberpositions[i]); if (mmd.getpersistencemodifier() != fieldpersistencemodifier.persistent) { continue; } if (mmds.size() == 1 && embmd != null && embmd.getownermember() != null && embmd.getownermember().equals(mmd.getname())) { continue; } abstractmembermetadata embmdmmd = null; if (embmd != null) { abstractmembermetadata[] embmdmmds = embmd.getmembermetadata(); if (embmdmmds != null) { for (abstractmembermetadata thismmd : embmdmmds) { if (thismmd.getname().equals(mmd.getname())) { embmdmmd = thismmd; break; } } } } relationtype relationtype = mmd.getrelationtype(clr); if (relationtype != relationtype.none && metadatautils.getinstance().ismemberembedded(mmgr, clr, mmd, relationtype, lastmmd)) { if (relationtype.isrelationsinglevalued(relationtype)) { boolean nested = false; if (storemgr.getsupportedoptions().contains(storemanager.option_orm_embedded_pc_nested)) { nested = !storemgr.getnucleuscontext().getconfiguration().getbooleanproperty(propertynames.property_metadata_embedded_pc_flat); string nestedstr = mmd.getvalueforextension("nested"); if (nestedstr != null && nestedstr.equalsignorecase("" + !nested)) { nested = !nested; } } list<abstractmembermetadata> embmmds = new arraylist<abstractmembermetadata>(mmds); embmmds.add(mmd); if (nested) { columnmetadata[] colmds = mmd.getcolumnmetadata(); string colname = namingfactory.getcolumnname(embmmds, 0); columnimpl col = addembeddedcolumn(colname, null); col.setnested(true); if (embmdmmd != null && embmdmmd.getcolumnmetadata() != null && embmdmmd.getcolumnmetadata().length == 1 && embmdmmd.getcolumnmetadata()[0].getposition() != null) { col.setposition(embmdmmd.getcolumnmetadata()[0].getposition()); } else if (colmds != null && colmds.length == 1 && colmds[0].getposition() != null) { col.setposition(colmds[0].getposition()); } if (embmdmmd != null && embmdmmd.getcolumnmetadata() != null && embmdmmd.getcolumnmetadata().length == 1 && embmdmmd.getcolumnmetadata()[0].getjdbctype() != null) { col.setjdbctype(embmdmmd.getcolumnmetadata()[0].getjdbctype()); } else if (colmds != null && colmds.length == 1 && colmds[0].getjdbctype() != null) { col.setjdbctype(colmds[0].getjdbctype()); } membercolumnmapping mapping = new membercolumnmappingimpl(mmd, col); col.setmembercolumnmapping(mapping); if (schemaverifier != null) { schemaverifier.attributeembeddedmember(mapping, embmmds); } mappingbyembeddedmember.put(getembeddedmembernavigatedpath(embmmds), mapping); } processembeddedmember(embmmds, mmgr.getmetadataforclass(mmd.gettype(), clr), clr, embmdmmd != null ? embmdmmd.getembeddedmetadata() : null, nested); } else { if (mmd.hascollection()) { if (storemgr.getsupportedoptions().contains(storemanager.option_orm_embedded_collection_nested)) { list<abstractmembermetadata> embmmds = new arraylist<abstractmembermetadata>(mmds); embmmds.add(mmd); columnmetadata[] colmds = mmd.getcolumnmetadata(); string colname = namingfactory.getcolumnname(embmmds, 0); columnimpl col = addembeddedcolumn(colname, null); col.setnested(true); if (embmdmmd != null && embmdmmd.getcolumnmetadata() != null && embmdmmd.getcolumnmetadata().length == 1 && embmdmmd.getcolumnmetadata()[0].getposition() != null) { col.setposition(embmdmmd.getcolumnmetadata()[0].getposition()); } else if (colmds != null && colmds.length == 1 && colmds[0].getposition() != null) { col.setposition(colmds[0].getposition()); } if (embmdmmd != null && embmdmmd.getcolumnmetadata() != null && embmdmmd.getcolumnmetadata().length == 1 && embmdmmd.getcolumnmetadata()[0].getjdbctype() != null) { col.setjdbctype(embmdmmd.getcolumnmetadata()[0].getjdbctype()); } else if (colmds != null && colmds.length == 1 && colmds[0].getjdbctype() != null) { col.setjdbctype(colmds[0].getjdbctype()); } membercolumnmapping mapping = new membercolumnmappingimpl(mmd, col); col.setmembercolumnmapping(mapping); if (schemaverifier != null) { schemaverifier.attributeembeddedmember(mapping, embmmds); } mappingbyembeddedmember.put(getembeddedmembernavigatedpath(embmmds), mapping); processembeddedmember(embmmds, mmgr.getmetadataforclass(mmd.getcollection().getelementtype(), clr), clr, embmdmmd != null ? embmdmmd.getembeddedmetadata() : null, true); } else { nucleuslogger.datastore_schema.warn("member " + mmd.getfullfieldname() + " is a (nested) embedded collection. not supported for this datastore so ignoring"); continue; } } else if (mmd.hasmap()) { if (storemgr.getsupportedoptions().contains(storemanager.option_orm_embedded_map_nested)) { nucleuslogger.datastore_schema.warn("member " + mmd.getfullfieldname() + " is a (nested) embedded map. not yet supported so ignoring"); } else { nucleuslogger.datastore_schema.warn("member " + mmd.getfullfieldname() + " is a (nested) embedded map. not supported for this datastore so ignoring"); continue; } } else if (mmd.hasarray()) { if (storemgr.getsupportedoptions().contains(storemanager.option_orm_embedded_array_nested)) { list<abstractmembermetadata> embmmds = new arraylist<abstractmembermetadata>(mmds); embmmds.add(mmd); columnmetadata[] colmds = mmd.getcolumnmetadata(); string colname = namingfactory.getcolumnname(embmmds, 0); columnimpl col = addembeddedcolumn(colname, null); col.setnested(true); if (embmdmmd != null && embmdmmd.getcolumnmetadata() != null && embmdmmd.getcolumnmetadata().length == 1 && embmdmmd.getcolumnmetadata()[0].getposition() != null) { col.setposition(embmdmmd.getcolumnmetadata()[0].getposition()); } else if (colmds != null && colmds.length == 1 && colmds[0].getposition() != null) { col.setposition(colmds[0].getposition()); } if (embmdmmd != null && embmdmmd.getcolumnmetadata() != null && embmdmmd.getcolumnmetadata().length == 1 && embmdmmd.getcolumnmetadata()[0].getjdbctype() != null) { col.setjdbctype(embmdmmd.getcolumnmetadata()[0].getjdbctype()); } else if (colmds != null && colmds.length == 1 && colmds[0].getjdbctype() != null) { col.setjdbctype(colmds[0].getjdbctype()); } membercolumnmapping mapping = new membercolumnmappingimpl(mmd, col); col.setmembercolumnmapping(mapping); if (schemaverifier != null) { schemaverifier.attributeembeddedmember(mapping, embmmds); } mappingbyembeddedmember.put(getembeddedmembernavigatedpath(embmmds), mapping); processembeddedmember(embmmds, mmgr.getmetadataforclass(mmd.getarray().getelementtype(), clr), clr, embmdmmd != null ? embmdmmd.getembeddedmetadata() : null, true); } else { nucleuslogger.datastore_schema.warn("member " + mmd.getfullfieldname() + " is a (nested) embedded array. not supported for this datastore so ignoring"); continue; } } } } else { list<abstractmembermetadata> embmmds = new arraylist<abstractmembermetadata>(mmds); embmmds.add(mmd); columnmetadata[] colmds = mmd.getcolumnmetadata(); if (relationtype != relationtype.none) { string colname = namingfactory.getcolumnname(embmmds, 0); columnimpl col = addembeddedcolumn(colname, null); col.setnested(ownernested); if (embmdmmd != null && embmdmmd.getcolumnmetadata() != null && embmdmmd.getcolumnmetadata().length == 1 && embmdmmd.getcolumnmetadata()[0].getposition() != null) { col.setposition(embmdmmd.getcolumnmetadata()[0].getposition()); } else if (colmds != null && colmds.length == 1 && colmds[0].getposition() != null) { col.setposition(colmds[0].getposition()); } if (embmdmmd != null && embmdmmd.getcolumnmetadata() != null && embmdmmd.getcolumnmetadata().length == 1 && embmdmmd.getcolumnmetadata()[0].getjdbctype() != null) { col.setjdbctype(embmdmmd.getcolumnmetadata()[0].getjdbctype()); } else if (colmds != null && colmds.length == 1 && colmds[0].getjdbctype() != null) { col.setjdbctype(colmds[0].getjdbctype()); } membercolumnmapping mapping = new membercolumnmappingimpl(mmd, col); col.setmembercolumnmapping(mapping); if (schemaverifier != null) { schemaverifier.attributeembeddedmember(mapping, embmmds); } mappingbyembeddedmember.put(getembeddedmembernavigatedpath(embmmds), mapping); } else { typeconverter typeconv = gettypeconverterformember(mmd, colmds, typemgr); if (typeconv != null) { if (typeconv instanceof multicolumnconverter) { class[] coljavatypes = ((multicolumnconverter)typeconv).getdatastorecolumntypes(); column[] cols = new column[coljavatypes.length]; for (int j=0;j<coljavatypes.length;j++) { string colname = namingfactory.getcolumnname(embmmds, j); columnimpl col = addembeddedcolumn(colname, typeconv); col.setnested(ownernested); if (embmdmmd != null && embmdmmd.getcolumnmetadata() != null && embmdmmd.getcolumnmetadata().length == coljavatypes.length && embmdmmd.getcolumnmetadata()[j].getposition() != null) { col.setposition(embmdmmd.getcolumnmetadata()[j].getposition()); } else if (colmds != null && colmds.length == coljavatypes.length && colmds[j].getposition() != null) { col.setposition(colmds[j].getposition()); } if (embmdmmd != null && embmdmmd.getcolumnmetadata() != null && embmdmmd.getcolumnmetadata().length == coljavatypes.length && embmdmmd.getcolumnmetadata()[j].getjdbctype() != null) { col.setjdbctype(embmdmmd.getcolumnmetadata()[j].getjdbctype()); } else if (colmds != null && colmds.length == coljavatypes.length && colmds[j].getjdbctype() != null) { col.setjdbctype(colmds[j].getjdbctype()); } cols[j] = col; } membercolumnmapping mapping = new membercolumnmappingimpl(mmd, cols, typeconv); for (int j=0;j<coljavatypes.length;j++) { ((columnimpl)cols[j]).setmembercolumnmapping(mapping); } if (schemaverifier != null) { schemaverifier.attributeembeddedmember(mapping, embmmds); } mappingbyembeddedmember.put(getembeddedmembernavigatedpath(embmmds), mapping); } else { string colname = namingfactory.getcolumnname(embmmds, 0); columnimpl col = addembeddedcolumn(colname, typeconv); col.setnested(ownernested); if (embmdmmd != null && embmdmmd.getcolumnmetadata() != null && embmdmmd.getcolumnmetadata().length == 1 && embmdmmd.getcolumnmetadata()[0].getposition() != null) { col.setposition(embmdmmd.getcolumnmetadata()[0].getposition()); } else if (colmds != null && colmds.length == 1 && colmds[0].getposition() != null) { col.setposition(colmds[0].getposition()); } if (embmdmmd != null && embmdmmd.getcolumnmetadata() != null && embmdmmd.getcolumnmetadata().length == 1 && embmdmmd.getcolumnmetadata()[0].getjdbctype() != null) { col.setjdbctype(embmdmmd.getcolumnmetadata()[0].getjdbctype()); } else if (colmds != null && colmds.length == 1 && colmds[0].getjdbctype() != null) { col.setjdbctype(colmds[0].getjdbctype()); } membercolumnmapping mapping = new membercolumnmappingimpl(mmd, col); col.setmembercolumnmapping(mapping); mapping.settypeconverter(typeconv); if (schemaverifier != null) { schemaverifier.attributeembeddedmember(mapping, embmmds); } mappingbyembeddedmember.put(getembeddedmembernavigatedpath(embmmds), mapping); } } else { string colname = namingfactory.getcolumnname(embmmds, 0); columnimpl col = addembeddedcolumn(colname, null); col.setnested(ownernested); abstractmembermetadata themmd = embmmds.get(0); if (themmd.isprimarykey()) { col.setprimarykey(); } if (embmdmmd != null && embmdmmd.getcolumnmetadata() != null && embmdmmd.getcolumnmetadata().length == 1 && embmdmmd.getcolumnmetadata()[0].getposition() != null) { col.setposition(embmdmmd.getcolumnmetadata()[0].getposition()); } else if (colmds != null && colmds.length == 1 && colmds[0].getposition() != null) { col.setposition(colmds[0].getposition()); } if (embmdmmd != null && embmdmmd.getcolumnmetadata() != null && embmdmmd.getcolumnmetadata().length == 1 && embmdmmd.getcolumnmetadata()[0].getjdbctype() != null) { col.setjdbctype(embmdmmd.getcolumnmetadata()[0].getjdbctype()); } else if (colmds != null && colmds.length == 1 && colmds[0].getjdbctype() != null) { col.setjdbctype(colmds[0].getjdbctype()); } membercolumnmapping mapping = new membercolumnmappingimpl(mmd, col); col.setmembercolumnmapping(mapping); if (schemaverifier != null) { schemaverifier.attributeembeddedmember(mapping, embmmds); } mappingbyembeddedmember.put(getembeddedmembernavigatedpath(embmmds), mapping); } } } } }