Package org.datanucleus.store

Examples of org.datanucleus.store.FieldValues


        }

        Object id = IdentityUtils.getApplicationIdentityForResultSetRow(ec, cmd, null, requiresInheritanceCheck,
            ((RDBMSStoreManager)ec.getStoreManager()).getFieldManagerForResultProcessing(ec, rs, resultMappings, cmd));

        return ec.findObject(id, new FieldValues()
        {
            public void fetchFields(ObjectProvider sm)
            {
                FieldManager fm =
                    ((MappedStoreManager)ec.getStoreManager()).getFieldManagerForResultProcessing(sm, rs, resultMappings);
View Full Code Here


        for (int i=0;i<fieldNumbers.length;i++)
        {
            resultMappings.addMappingForMember(fieldNumbers[i], stmtMappings[fieldNumbers[i]]);
        }

        return ec.findObject(oid, new FieldValues()
        {
            public void fetchFields(ObjectProvider sm)
            {
                FieldManager fm =
                    ((MappedStoreManager)ec.getStoreManager()).getFieldManagerForResultProcessing(sm, rs, resultMappings);
View Full Code Here

        {
            // Any single-field identity will have the precise target class determined above, so use it
            pcClass = ec.getApiAdapter().getTargetClassForSingleFieldIdentity(id);
        }

        return ec.findObject(id, new FieldValues()
        {
            public void fetchFields(ObjectProvider sm)
            {
                FieldManager fm = storeMgr.getFieldManagerForResultProcessing(sm, resultSet, mappingDefinition);
                sm.replaceFields(fieldNumbers, fm, false);
View Full Code Here

        {
            return null;
        }

        final MappedStoreManager storeMgr = (MappedStoreManager)ec.getStoreManager();
        return ec.findObject(oid, new FieldValues()
        {
            public void fetchFields(ObjectProvider sm)
            {
                FieldManager fm = storeMgr.getFieldManagerForResultProcessing(sm, resultSet,
                    mappingDefinition);
View Full Code Here

        }

        // Make sure that the element is persisted in the datastore (reachability)
        final Object newOwner = sm.getObject();
        ExecutionContext ec = sm.getExecutionContext();
        boolean inserted = validateElementForWriting(sm, element, new FieldValues()
        {
            public void fetchFields(ObjectProvider esm)
            {
                // Find the (element) table storing the FK back to the owner
                boolean isPersistentInterface = storeMgr.getNucleusContext().getMetaDataManager().isPersistentInterface(elementType);
View Full Code Here

    protected boolean validateElementForWriting(final ObjectProvider sm, Object element, final int index)
    {
        final Object newOwner = sm.getObject();

        // Check if element is ok for use in the datastore, specifying any external mappings that may be required
        boolean inserted = super.validateElementForWriting(sm, element, new FieldValues()
        {
            public void fetchFields(ObjectProvider esm)
            {
                // Find the (element) table storing the FK back to the owner
                boolean isPersistentInterface = storeMgr.getNucleusContext().getMetaDataManager().isPersistentInterface(elementType);
View Full Code Here

                     * Update its owner and key fields to the appropriate values and
                     * *then* make it persistent.  Making the changes before DB
                     * insertion avoids an unnecessary UPDATE allows the owner
                     * and/or key fields to be non-nullable.
                     */
                    ec.persistObjectInternal(newValue, new FieldValues()
                        {
                        public void fetchFields(ObjectProvider vsm)
                        {
                            if (ownerFieldNumber >= 0)
                            {
                                vsm.replaceFieldMakeDirty(ownerFieldNumber, newOwner);
                            }
                            vsm.replaceFieldMakeDirty(keyFieldNumber, newKey);

                            JavaTypeMapping externalFKMapping = valueTable.getExternalMapping(ownerMemberMetaData, MappingConsumer.MAPPING_TYPE_EXTERNAL_FK);
                            if (externalFKMapping != null)
                            {
                                // Set the owner in the value object where appropriate
                                vsm.setAssociatedValue(externalFKMapping, sm.getObject());
                            }
                        }
                        public void fetchNonLoadedFields(ObjectProvider sm)
                        {
                        }
                        public FetchPlan getFetchPlanForLoading()
                        {
                            return null;
                        }
                        }, ObjectProvider.PC);

      /*              // TODO Think about removing this since we set the associated value here
                    if (ownerFieldNumber < 0)
                    {
                        updateValueFk(sm, newValue, newOwner);
                    }*/
                }
            }
            else
            {
                // Value is stored in the key
                ExecutionContext ec = sm.getExecutionContext();
                final Object newOwner = sm.getObject();

                if (ec.getApiAdapter().isPersistent(newKey))
                {
                    /*
                     * The new key is already persistent.
                     *
                     * "Put" the new key in the map by updating its owner and value
                     * fields to the appropriate values. This is done with the same
                     * methods the PC itself would use if the application code
                     * modified the fields. It should result in no actual database
                     * activity if the fields were already set to the right values.
                     */
                    if (ec != ec.getApiAdapter().getExecutionContext(newKey))
                    {
                        throw new NucleusUserException(LOCALISER.msg("056060"),
                            ec.getApiAdapter().getIdForObject(newKey));
                    }

                    ObjectProvider vsm = ec.findObjectProvider(newKey);

                    // Ensure the current owner field is loaded, and replace with new key
                    if (ownerFieldNumber >= 0)
                    {
                        ec.getApiAdapter().isLoaded(vsm, ownerFieldNumber);
                        Object oldOwner = vsm.provideField(ownerFieldNumber);
                        vsm.replaceFieldMakeDirty(ownerFieldNumber, newOwner);
                        if (ec.getManageRelations())
                        {
                            ec.getRelationshipManager(vsm).relationChange(ownerFieldNumber, oldOwner, newOwner);
                        }
                    }
                    else
                    {
                        updateKeyFk(sm, newKey, newOwner);
                    }

                    // Ensure the current value field is loaded, and replace with new value
                    ec.getApiAdapter().isLoaded(vsm, valueFieldNumber);
                    oldValue = vsm.provideField(valueFieldNumber); // TODO Should we update the local variable ?
                    vsm.replaceFieldMakeDirty(valueFieldNumber, newValue);
                    if (ec.getManageRelations())
                    {
                        ec.getRelationshipManager(vsm).relationChange(valueFieldNumber, oldValue, newValue);
                    }
                }
                else
                {
                    /*
                     * The new key is not yet persistent.
                     *
                     * Update its owner and key fields to the appropriate values and
                     * *then* make it persistent.  Making the changes before DB
                     * insertion avoids an unnecessary UPDATE allows the owner
                     * and/or key fields to be non-nullable.
                     */
                    final Object newValueObj = newValue;
                    ec.persistObjectInternal(newKey, new FieldValues()
                        {
                        public void fetchFields(ObjectProvider vsm)
                        {
                            if (ownerFieldNumber >= 0)
                            {
View Full Code Here

        for (int i=0;i<pkFieldNumbers.length;i++)
        {
            resultMappings.addMappingForMember(pkFieldNumbers[i], statementExpressionIndex[pkFieldNumbers[i]]);
        }
        return ec.findObjectUsingAID(new Type(clr.classForName(cmd.getFullClassName())),
            new FieldValues()
            {
                // StateManager calls the fetchFields method
                public void fetchFields(ObjectProvider sm)
                {
                    sm.replaceFields(pkFieldNumbers,
View Full Code Here

    }

    // Make sure that the element is persisted in the datastore (reachability)
    final Object newOwner = op.getObject();
    ExecutionContext ec = op.getExecutionContext();
    boolean inserted = validateElementForWriting(ec, element, new FieldValues() {
      public void fetchFields(ObjectProvider esm) {
        // Find the (element) table storing the FK back to the owner
        JavaTypeMapping externalFKMapping = elementTable.getExternalMapping(ownerMemberMetaData,
            MappingConsumer.MAPPING_TYPE_EXTERNAL_FK);
        if (externalFKMapping != null) {
View Full Code Here

   * @return The pojo that corresponds to the id of the provided entity.
   */
  private static Object entityToPojoPrimaryKey(final Entity entity, final AbstractClassMetaData acmd,
      ClassLoaderResolver clr, ExecutionContext ec) {

    FieldValues fv = new FieldValues() {
      public void fetchFields(ObjectProvider op) {
        op.replaceFields(acmd.getPKMemberPositions(), new FetchFieldManager(op, entity));
      }
      public void fetchNonLoadedFields(ObjectProvider op) {}
      public FetchPlan getFetchPlanForLoading() {
View Full Code Here

TOP

Related Classes of org.datanucleus.store.FieldValues

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.