Package org.datanucleus.store.mapped.mapping

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


                debugMapping(keyMapping);
            }
            if (valueKeyFieldName != null && isEmbeddedKeyPC())
            {
                // Key (PC) is embedded and value is a field of the key
                EmbeddedKeyPCMapping embMapping = (EmbeddedKeyPCMapping)keyMapping;
                valueMapping = embMapping.getJavaTypeMapping(valueKeyFieldName);
            }
        }
        else
        {
            // Key = PC
            ColumnMetaData[] keyColmd = null;
            KeyMetaData keymd = mmd.getKeyMetaData();
            if (keymd != null && keymd.getColumnMetaData() != null && keymd.getColumnMetaData().length > 0)
            {
                // Column mappings defined at this side (1-N, M-N)
                keyColmd = keymd.getColumnMetaData();
            }
            keyMapping = ColumnCreator.createColumnsForJoinTables(keyCls, mmd, keyColmd, storeMgr, this,
                false, false, FieldRole.ROLE_MAP_KEY, clr);
            if (mmd.getContainer().allowNulls() == Boolean.TRUE)
            {
                // Make all key col(s) nullable so we can store null elements
                for (int i=0;i<keyMapping.getNumberOfDatastoreMappings();i++)
                {
                    Column elementCol = (Column)keyMapping.getDatastoreMapping(i).getDatastoreField();
                    elementCol.setNullable();
                }
            }
            if (NucleusLogger.DATASTORE.isDebugEnabled())
            {
                debugMapping(keyMapping);
            }
        }

        // Add value mapping
        boolean valuePC = (mmd.hasMap() && mmd.getMap().valueIsPersistent());
        Class valueCls = clr.classForName(mapmd.getValueType());
        if (valueKeyFieldName != null && isEmbeddedKeyPC())
        {
            // Added in key code
        }
        else if (isSerialisedValue() || isEmbeddedValuePC() || (isEmbeddedValue() && !valuePC) ||
            ClassUtils.isReferenceType(valueCls))
        {
            // Value = PC(embedded), PC(serialised), Non-PC(serialised), Non-PC(embedded), Reference
            valueMapping = storeMgr.getMappingManager().getMapping(this, mmd, clr, FieldRole.ROLE_MAP_VALUE);
            if (mmd.getContainer().allowNulls() == Boolean.TRUE)
            {
                // Make all value col(s) nullable so we can store null elements
                for (int i=0;i<valueMapping.getNumberOfDatastoreMappings();i++)
                {
                    Column elementCol = (Column)valueMapping.getDatastoreMapping(i).getDatastoreField();
                    elementCol.setNullable();
                }
            }
            if (NucleusLogger.DATASTORE.isDebugEnabled())
            {
                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 (!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

        Set indices = super.getExpectedIndices(clr);

        if (keyMapping instanceof EmbeddedKeyPCMapping)
        {
            // Add all indices required by fields of the embedded key
            EmbeddedKeyPCMapping embMapping = (EmbeddedKeyPCMapping)keyMapping;
            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)
                    {
                        indices.add(index);
                    }
                }
            }
        }

        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

        List candidateKeys = super.getExpectedCandidateKeys();

        if (keyMapping instanceof EmbeddedKeyPCMapping)
        {
            // Add all candidate keys required by fields of the embedded key
            EmbeddedKeyPCMapping embMapping = (EmbeddedKeyPCMapping)keyMapping;
            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)
                    {
                        candidateKeys.add(ck);
                    }
                }
            }
        }

        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 populateEmbeddedKeyFieldsInStatement(ObjectProvider sm, Object key,
            PreparedStatement ps, int jdbcPosition, JoinTable joinTable, AbstractMapStore mapStore)
    {
        AbstractClassMetaData kmd = mapStore.getKmd();
        EmbeddedKeyPCMapping embeddedMapping = (EmbeddedKeyPCMapping)mapStore.getKeyMapping();
        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 = kmd.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());
        }

        EmbeddedKeyPCMapping embeddedMapping = (EmbeddedKeyPCMapping)keyMapping;
        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.EmbeddedKeyPCMapping

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.