Package org.datanucleus.store.mapped

Examples of org.datanucleus.store.mapped.StatementMappingIndex


        return mapIdx.getMapping().getChar(ec, resultSet, mapIdx.getColumnPositions());
    }

    public byte fetchByteField(int fieldNumber)
    {
        StatementMappingIndex mapIdx = resultMappings.getMappingForMemberPosition(fieldNumber);
        return mapIdx.getMapping().getByte(ec, resultSet, mapIdx.getColumnPositions());
    }
View Full Code Here


        return mapIdx.getMapping().getByte(ec, resultSet, mapIdx.getColumnPositions());
    }

    public short fetchShortField(int fieldNumber)
    {
        StatementMappingIndex mapIdx = resultMappings.getMappingForMemberPosition(fieldNumber);
        return mapIdx.getMapping().getShort(ec, resultSet, mapIdx.getColumnPositions());
    }
View Full Code Here

        return mapIdx.getMapping().getShort(ec, resultSet, mapIdx.getColumnPositions());
    }

    public int fetchIntField(int fieldNumber)
    {
        StatementMappingIndex mapIdx = resultMappings.getMappingForMemberPosition(fieldNumber);
        return mapIdx.getMapping().getInt(ec, resultSet, mapIdx.getColumnPositions());
    }
View Full Code Here

        return mapIdx.getMapping().getInt(ec, resultSet, mapIdx.getColumnPositions());
    }

    public long fetchLongField(int fieldNumber)
    {
        StatementMappingIndex mapIdx = resultMappings.getMappingForMemberPosition(fieldNumber);
        return mapIdx.getMapping().getLong(ec, resultSet, mapIdx.getColumnPositions());
    }
View Full Code Here

        return mapIdx.getMapping().getLong(ec, resultSet, mapIdx.getColumnPositions());
    }

    public float fetchFloatField(int fieldNumber)
    {
        StatementMappingIndex mapIdx = resultMappings.getMappingForMemberPosition(fieldNumber);
        return mapIdx.getMapping().getFloat(ec, resultSet, mapIdx.getColumnPositions());
    }
View Full Code Here

        return mapIdx.getMapping().getFloat(ec, resultSet, mapIdx.getColumnPositions());
    }

    public double fetchDoubleField(int fieldNumber)
    {
        StatementMappingIndex mapIdx = resultMappings.getMappingForMemberPosition(fieldNumber);
        return mapIdx.getMapping().getDouble(ec, resultSet, mapIdx.getColumnPositions());
    }
View Full Code Here

        return mapIdx.getMapping().getDouble(ec, resultSet, mapIdx.getColumnPositions());
    }

    public String fetchStringField(int fieldNumber)
    {
        StatementMappingIndex mapIdx = resultMappings.getMappingForMemberPosition(fieldNumber);
        return mapIdx.getMapping().getString(ec, resultSet, mapIdx.getColumnPositions());
    }
View Full Code Here

        return mapIdx.getMapping().getString(ec, resultSet, mapIdx.getColumnPositions());
    }

    public Object fetchObjectField(int fieldNumber)
    {
        StatementMappingIndex mapIdx = resultMappings.getMappingForMemberPosition(fieldNumber);
        JavaTypeMapping mapping = mapIdx.getMapping();
        Object value;
        if (mapping instanceof EmbeddedPCMapping ||
            mapping instanceof SerialisedPCMapping ||
            mapping instanceof SerialisedReferenceMapping)
        {
            value = mapping.getObject(ec, resultSet, mapIdx.getColumnPositions(), sm, fieldNumber);
        }
        else
        {
            AbstractMemberMetaData mmd = cmd.getMetaDataForManagedMemberAtAbsolutePosition(fieldNumber);
            int relationType = mmd.getRelationType(ec.getClassLoaderResolver());
            if (relationType == Relation.ONE_TO_ONE_BI || relationType == Relation.ONE_TO_ONE_UNI ||
                relationType == Relation.MANY_TO_ONE_BI)
            {
                // Process fields of sub-object if available in this result set
                StatementClassMapping relationMappings =
                    resultMappings.getMappingDefinitionForMemberPosition(fieldNumber);
                if (relationMappings != null)
                {
                    ClassLoaderResolver clr = ec.getClassLoaderResolver();
                    AbstractClassMetaData relatedCmd = ec.getMetaDataManager().getMetaDataForClass(mmd.getType(), clr);
                    ResultObjectFactory relationROF =
                        ((MappedStoreManager)ec.getStoreManager()).newResultObjectFactory(relatedCmd,
                            relationMappings, false, ec.getFetchPlan(), mmd.getType());
                    value = relationROF.getObject(ec, resultSet);
                }
                else
                {
                    value = mapping.getObject(ec, resultSet, mapIdx.getColumnPositions());
                }
            }
            else
            {
                value = mapping.getObject(ec, resultSet, mapIdx.getColumnPositions());
            }
        }

        // Return the field value (as a wrapper if wrappable)
        if (sm != null)
View Full Code Here

            {
                if (fmd.isPrimaryKey())
                {
                    Integer abs_field_num = Integer.valueOf(fmd.getAbsoluteFieldNumber());
                    int parametersIndex[] = new int[m.getNumberOfDatastoreMappings()];
                    StatementMappingIndex sei = new StatementMappingIndex(m);
                    sei.addParameterOccurrence(parametersIndex);

                    mappingStatementIndex.getPrimaryKeys()[fmd.getAbsoluteFieldNumber()] = sei;
                    for (int j=0; j<parametersIndex.length; j++)
                    {
                        if (where.length() > 0)
                        {
                            where.append(" AND ");
                        }
                        String condition = m.getDatastoreMapping(j).getDatastoreField().getIdentifier() +
                            "=" + ((RDBMSMapping)m.getDatastoreMapping(j)).getUpdateInputParameter();
                        where.append(condition);

                        if (!pkFields.contains(abs_field_num))
                        {
                            pkFields.add(abs_field_num);
                        }
                        parametersIndex[j] = paramIndex++;
                    }
                }
                else if (m instanceof PersistableMapping || m instanceof ReferenceMapping)
                {
                    if (m.getNumberOfDatastoreMappings() == 0)
                    {
                        // Field storing a PC object with FK at other side
                        int relationType = fmd.getRelationType(clr);
                        if (relationType == Relation.ONE_TO_ONE_BI)
                        {
                            if (fmd.getMappedBy() != null)
                            {
                                // 1-1 bidirectional field without datastore column(s) (with single FK at other side)
                                oneToOneNonOwnerFields.add(fmd);
                            }
                        }
                        else if (relationType == Relation.MANY_TO_ONE_BI)
                        {
                            AbstractMemberMetaData[] relatedMmds = fmd.getRelatedMemberMetaData(clr);
                            if (fmd.getJoinMetaData() != null || relatedMmds[0].getJoinMetaData() != null)
                            {
                                // 1-N bidirectional using join table for relation
                                // TODO Anything to do here ?
                            }
                        }
                    }
                }
                else
                {
                    if (whereClauseConsumption)
                    {
                        // Must be version field since nothing else should come through here
                        int parametersIndex[] = new int[m.getNumberOfDatastoreMappings()];
                        parametersIndex[0] = paramIndex++;
                        StatementMappingIndex sei = new StatementMappingIndex(m);
                        sei.addParameterOccurrence(parametersIndex);
                        mappingStatementIndex.setVersion2(sei);
                        String inputParam = ((RDBMSMapping)m.getDatastoreMapping(0)).getUpdateInputParameter();
                        String condition = " AND " + m.getDatastoreMapping(0).getDatastoreField().getIdentifier() + "=" + inputParam;
                        where.append(condition);
                    }
View Full Code Here

         */
        public void consumeMapping(JavaTypeMapping m, int mappingType)
        {
            if (mappingType == MappingConsumer.MAPPING_TYPE_DATASTORE_ID)
            {
                StatementMappingIndex datastoreMappingIdx = new StatementMappingIndex(m);
                mappingStatementIndex.setDatastoreId(datastoreMappingIdx);
                where.append(m.getDatastoreMapping(0).getDatastoreField().getIdentifier().toString());
                where.append("=");
                where.append(((RDBMSMapping)m.getDatastoreMapping(0)).getUpdateInputParameter());

                int[] param = { paramIndex++ };
                datastoreMappingIdx.addParameterOccurrence(param);
            }
            else if (mappingType == MappingConsumer.MAPPING_TYPE_VERSION)
            {
                if (whereClauseConsumption)
                {
                    StatementMappingIndex versStmtIdx = new StatementMappingIndex(m);
                    mappingStatementIndex.setVersion2(versStmtIdx);
                    int[] param = { paramIndex++ };
                    versStmtIdx.addParameterOccurrence(param);
                    String inputParam = ((RDBMSMapping)m.getDatastoreMapping(0)).getUpdateInputParameter();
                    String condition = " AND " + m.getDatastoreMapping(0).getDatastoreField().getIdentifier() + "=" + inputParam;
                    where.append(condition);
                }
            }
View Full Code Here

TOP

Related Classes of org.datanucleus.store.mapped.StatementMappingIndex

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.