Package org.datanucleus.identity

Examples of org.datanucleus.identity.OID


                // If the field doesn't map to any datastore fields (e.g remote FK), omit the set process
                if (getNumberOfDatastoreMappings() > 0)
                {
                    if (id instanceof OID)
                    {
                        OID oid = (OID)id;
                        try
                        {
                            // Try as a Long
                            getDatastoreMapping(0).setObject(ps, param[0], oid.getKeyValue());
                        }
                        catch (Exception e)
                        {
                            // Must be a String
                            getDatastoreMapping(0).setObject(ps, param[0], oid.getKeyValue().toString());
                        }
                    }
                    else
                    {
                        boolean fieldsSet = false;
View Full Code Here


      childPC = ec.persistObjectInternal(childPC, null, -1, ObjectProvider.PC);
      childOP = ec.findObjectProvider(childPC);
    }

    if (mmd.getAbstractClassMetaData().getIdentityType() == IdentityType.DATASTORE) {
      OID oid = (OID)childOP.getInternalObjectId();
      if (oid == null) {
        // Object has not yet flushed to the datastore
        childOP.flush();
      }
    } else {
View Full Code Here

        }
        if(jdoOid instanceof javax.jdo.identity.LongIdentity) {
            return "l" + SEPARATOR + jdoOid;
        }
        if(jdoOid instanceof OID) {
            OID dnOid = (OID) jdoOid;
            Object keyValue = dnOid.getKeyValue();
           
            // prettier handling of these common cases
            if(keyValue instanceof String) {
                return "S" + SEPARATOR + keyValue;
            }
View Full Code Here

        if (cmd.getIdentityType() == IdentityType.DATASTORE &&
            cmd.getIdentityMetaData().getValueStrategy() != IdentityStrategy.IDENTITY)
        {
            // Add surrogate datastore identity field (if using identity then just uses "_id" MongoDB special)
            String fieldName = MongoDBUtils.getFieldName(cmd.getIdentityMetaData());
            OID oid = (OID) op.getInternalObjectId();
            Object key = oid.getKeyValue();
            dbObject.put(fieldName, key);
        }

        if (cmd.hasDiscriminatorStrategy())
        {
View Full Code Here

            }
        }
        else if (cmd.getIdentityType() == IdentityType.DATASTORE)
        {
            // Add PK field to the query object
            OID oid = (OID) sm.getObjectId();
            if (oid == null && cmd.getIdentityMetaData().getValueStrategy() == IdentityStrategy.IDENTITY)
            {
                // Not yet set, so return null (needs to be attributed in the datastore)
                return null;
            }
            Object value = oid.getKeyValue();
            if (cmd.getIdentityMetaData().getValueStrategy() == IdentityStrategy.IDENTITY)
            {
                query.put("_id", value);
            }
            else
View Full Code Here

        }
        else
        {
            idKey = dbObject.get(MongoDBUtils.getFieldName(cmd.getIdentityMetaData()));
        }
        OID oid = OIDFactory.getInstance(ec.getNucleusContext(), cmd.getFullClassName(), idKey);
        Object pc = ec.findObject(oid,
            new FieldValues()
            {
                // StateManager calls the fetchFields method
                public void fetchFields(ObjectProvider sm)
View Full Code Here

                    {
                        // Datastore identity
                        for (int i=0; i<expr.expressionList.size(); i++)
                        {
                            ScalarExpression source = expr.expressionList.getExpression(i);
                            OID objectId = (OID)api.getIdForObject(value);
                            if (objectId == null)
                            {
                                // PC object with no id (embedded, or transient maybe)
                                // Query should return nothing (so just do "(1 = 0)")
                                NucleusLogger.QUERY.warn(LOCALISER.msg("037003", value));
                                bExpr = new BooleanLiteral(qs, mapping, false).eq(new BooleanLiteral(qs, mapping, true));
                                // It is arguable that we should compare the id with null (as below)
                                /*bExpr = expr.eq(new NullLiteral(qs));*/
                            }
                            else
                            {
                                JavaTypeMapping m = storeMgr.getMappingManager().getMappingWithDatastoreMapping(
                                    objectId.getKeyValue().getClass(), false, false, clr);
                                ScalarExpression oidExpr = m.newLiteral(qs, objectId.getKeyValue());
                                bExpr = source.eq(oidExpr);
                            }
                        }
                    }
                }
View Full Code Here

            getDataStoreMapping(0).setObject(ps, param[0], null);
        }
        else
        {
            ApiAdapter api = om.getApiAdapter();
            OID oid;
            if (api.isPersistable(value))
            {
                oid = (OID) api.getIdForObject(value);
                if (oid == null)
                {
                    if (om.isInserting(value))
                    {
                        // Object is in the process of being inserted, but has no id yet so provide a null for now
                        // The "NotYetFlushedException" is caught by ParameterSetter and processed as an update being required.
                        getDataStoreMapping(0).setObject(ps, param[0], null);
                        throw new NotYetFlushedException(value);
                    }
                    else
                    {
                        // Object is not persist, nor in the process of being made persistent
                        om.persistObjectInternal(value, null, null, -1, StateManager.PC);
                        om.flushInternal(false);
                    }
                }
                oid = (OID) api.getIdForObject(value);
            }
            else
            {
                oid = (OID) value;
            }

            try
            {
                // Try as a Long
                getDataStoreMapping(0).setObject(ps,param[0],oid.getKeyValue());
            }
            catch (Exception e)
            {
                // Must be a String
                getDataStoreMapping(0).setObject(ps,param[0],oid.getKeyValue().toString());
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.datanucleus.identity.OID

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.