Package org.datanucleus.store.mapped.mapping

Examples of org.datanucleus.store.mapped.mapping.EmbeddedValuePCMapping


                debugMapping(valueMapping);
            }
            if (keyValueFieldName != null && isEmbeddedValuePC())
            {
                // Value (PC) is embedded and key is a field of the value
                EmbeddedValuePCMapping embMapping = (EmbeddedValuePCMapping)valueMapping;
                keyMapping = embMapping.getJavaTypeMapping(keyValueFieldName);
            }
        }
        else
        {
            // Value = PC
View Full Code Here


            if (!isSerialisedValuePC())
            {
                if (isEmbeddedValuePC())
                {
                    // Add any FKs for the fields of the (embedded) value
                    EmbeddedValuePCMapping embMapping = (EmbeddedValuePCMapping)valueMapping;
                    for (int i=0;i<embMapping.getNumberOfJavaTypeMappings();i++)
                    {
                        JavaTypeMapping embFieldMapping = embMapping.getJavaTypeMapping(i);
                        AbstractMemberMetaData embFmd = embFieldMapping.getMemberMetaData();
                        if (ClassUtils.isReferenceType(embFmd.getType()) &&
                            embFieldMapping instanceof ReferenceMapping)
                        {
                            // Field is a reference type, so add a FK to the table of the PC for each PC implementation
                            Collection fks = TableUtils.getForeignKeysForReferenceField(embFieldMapping, embFmd,
                                autoMode, storeMgr, clr);
                            foreignKeys.addAll(fks);
                        }
                        else if (storeMgr.getNucleusContext().getMetaDataManager().getMetaDataForClass(embFmd.getType(), clr) != null &&
                                embFieldMapping.getNumberOfDatastoreMappings() > 0 &&
                                embFieldMapping instanceof PersistableMapping)
                        {
                            // Field is for a PC class with the FK at this side, so add a FK to the table of this PC
                            ForeignKey fk = TableUtils.getForeignKeyForPCField(embFieldMapping, embFmd,
                                autoMode, storeMgr, clr);
                            if (fk != null)
                            {
                                foreignKeys.add(fk);
                            }
                        }
                    }
                }
                else if (mmd.getMap().valueIsPersistent())
                {
                    // FK from join table to value table
                    referencedTable = storeMgr.getDatastoreClass(mmd.getMap().getValueType(), clr);
                    if (referencedTable != null)
                    {
                        // Take <foreign-key> from <value>
                        ForeignKeyMetaData fkmd = null;
                        if (mmd.getValueMetaData() != null)
                        {
                            fkmd = mmd.getValueMetaData().getForeignKeyMetaData();
                        }
                        if (fkmd != null || autoMode)
                        {
                            ForeignKey fk = new ForeignKey(valueMapping, dba, referencedTable, true);
                            fk.setForMetaData(fkmd);
                            foreignKeys.add(fk);
                        }
                    }
                }
            }

            if (!isSerialisedKeyPC())
            {
                if (isEmbeddedKeyPC())
                {
                    // Add any FKs for the fields of the (embedded) key
                    EmbeddedKeyPCMapping embMapping = (EmbeddedKeyPCMapping)keyMapping;
                    for (int i=0;i<embMapping.getNumberOfJavaTypeMappings();i++)
                    {
                        JavaTypeMapping embFieldMapping = embMapping.getJavaTypeMapping(i);
                        AbstractMemberMetaData embFmd = embFieldMapping.getMemberMetaData();
                        if (ClassUtils.isReferenceType(embFmd.getType()) &&
                            embFieldMapping instanceof ReferenceMapping)
                        {
                            // Field is a reference type, so add a FK to the table of the PC for each PC implementation
View Full Code Here

        }

        if (valueMapping instanceof EmbeddedValuePCMapping)
        {
            // Add all indices required by fields of the embedded value
            EmbeddedValuePCMapping embMapping = (EmbeddedValuePCMapping)valueMapping;
            for (int i=0;i<embMapping.getNumberOfJavaTypeMappings();i++)
            {
                JavaTypeMapping embFieldMapping = embMapping.getJavaTypeMapping(i);
                IndexMetaData imd = embFieldMapping.getMemberMetaData().getIndexMetaData();
                if (imd != null)
                {
                    Index index = TableUtils.getIndexForField(this, imd, embFieldMapping);
                    if (index != null)
View Full Code Here

        }

        if (valueMapping instanceof EmbeddedValuePCMapping)
        {
            // Add all candidate keys required by fields of the embedded value
            EmbeddedValuePCMapping embMapping = (EmbeddedValuePCMapping)valueMapping;
            for (int i=0;i<embMapping.getNumberOfJavaTypeMappings();i++)
            {
                JavaTypeMapping embFieldMapping = embMapping.getJavaTypeMapping(i);
                UniqueMetaData umd = embFieldMapping.getMemberMetaData().getUniqueMetaData();
                if (umd != null)
                {
                    CandidateKey ck = TableUtils.getCandidateKeyForField(this, umd, embFieldMapping);
                    if (ck != null)
View Full Code Here

     */
    public static int populateEmbeddedValueFieldsInStatement(ObjectProvider sm, Object value,
            PreparedStatement ps, int jdbcPosition, JoinTable joinTable, AbstractMapStore mapStore)
    {
        AbstractClassMetaData vmd = mapStore.getVmd();
        EmbeddedValuePCMapping embeddedMapping = (EmbeddedValuePCMapping)mapStore.getValueMapping();
        StatementClassMapping mappingDefinition = new StatementClassMapping();
        int[] elementFieldNumbers = new int[embeddedMapping.getNumberOfJavaTypeMappings()];
        for (int i=0;i<embeddedMapping.getNumberOfJavaTypeMappings();i++)
        {
            JavaTypeMapping fieldMapping = embeddedMapping.getJavaTypeMapping(i);
            int absFieldNum = vmd.getAbsolutePositionOfMember(fieldMapping.getMemberMetaData().getName());
            elementFieldNumbers[i] = absFieldNum;
            StatementMappingIndex stmtMapping = new StatementMappingIndex(fieldMapping);
            int[] jdbcParamPositions = new int[fieldMapping.getNumberOfDatastoreMappings()];
            for (int j=0;j<fieldMapping.getNumberOfDatastoreMappings();j++)
View Full Code Here

            stmt.append(ownerMapping.getDatastoreMapping(i).getDatastoreField().getIdentifier().toString());
            stmt.append(" = ");
            stmt.append(((RDBMSMapping)ownerMapping.getDatastoreMapping(i)).getUpdateInputParameter());
        }

        EmbeddedValuePCMapping embeddedMapping = (EmbeddedValuePCMapping)valueMapping;
        for (int i=0;i<embeddedMapping.getNumberOfJavaTypeMappings();i++)
        {
            JavaTypeMapping m = embeddedMapping.getJavaTypeMapping(i);
            if (m != null)
            {
                for (int j=0;j<m.getNumberOfDatastoreMappings();j++)
                {
                    stmt.append(" AND ");
View Full Code Here

TOP

Related Classes of org.datanucleus.store.mapped.mapping.EmbeddedValuePCMapping

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.