Package javax.jdo.spi

Examples of javax.jdo.spi.PersistenceCapable$ObjectIdFieldSupplier


  super(mgr);
    }

    public Object go() {
  System.out.println("QUERY FOR OBJECTS");
  PersistenceCapable pc = null;
  try {
      Class clazz = null;
      while (clazz == null) {
    System.out.print("Enter result class: ");
    clazz = readClass();
View Full Code Here


                            LOCALISER.msg("055009",
                            StringUtils.toJVMIDString(sm.getObject()),
                            ownerMemberMetaData.getFullFieldName(),
                            StringUtils.toJVMIDString(element)));
                    }
                    PersistenceCapable pcElement = (PersistenceCapable) element;
                    elementSM.setObjectField(pcElement, getFieldNumberInElementForBidirectional(elementSM), oldOwner, newOwner);
                    if (om.isFlushing())
                    {
                        elementSM.flush();
                    }
View Full Code Here

            om.deleteObjectInternal(element);
        }
        else if (ownerMapping.isNullable())
        {
            // Bidirectional 1-N, so nullify the owner
            PersistenceCapable pcElement = (PersistenceCapable) element;
            if (ownerFieldNumber >= 0)
            {
                esm.setObjectField(pcElement, ownerFieldNumber, oldOwner, null);
            }
            // Unidirectional 1-N, so nullify the owner
View Full Code Here

                     * 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.
                     */
                    PersistenceCapable newValuePC = (PersistenceCapable)newValue;
                    if (om != ObjectManagerHelper.getObjectManager(newValue))
                    {
                        throw new JPOXUserException(LOCALISER.msg("RDBMS.SCO.Map.WriteValudInvalidWithDifferentPM"), newValuePC.jdoGetObjectId());
                    }

                    StateManager vsm = om.findStateManager(newValue);
                   
                    // Ensure the current owner field is loaded, and replace with new value
                    if (ownerFieldNumber >= 0)
                    {
                        om.getApiAdapter().isLoaded(vsm, ownerFieldNumber);
                        Object oldOwner = vsm.provideField(ownerFieldNumber);
                        vsm.setObjectField(newValuePC, ownerFieldNumber, oldOwner, newOwner);
                    }
                    else
                    {
                        updateValueFk(sm, newValue, newOwner);
                    }
                   
                    // Ensure the current key field is loaded, and replace with new value
                    om.getApiAdapter().isLoaded(vsm, keyFieldNumber);
                    Object oldKey = vsm.provideField(keyFieldNumber);
                    vsm.setObjectField(newValuePC, keyFieldNumber, oldKey, newKey);
                }
                else
                {                 
                    /*
                     * The new value 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.
                     */
                    om.persistObjectInternal(newValue, new FieldValues()
                        {
                        public void fetchFields(StateManager vsm)
                        {
                            if (ownerFieldNumber >= 0)
                            {
                                vsm.replaceField(ownerFieldNumber, newOwner, true);
                            }
                            vsm.replaceField(keyFieldNumber, newKey, true);
                        }
                        public void fetchNonLoadedFields(StateManager sm)
                        {
                        }
                        public FetchPlan getFetchPlanForLoading()
                        {
                            return null;
                        }
                        }, null, -1, StateManager.PC);
                    if (ownerFieldNumber < 0)
                    {
                        updateValueFk(sm, newValue, newOwner);
                    }
                }
            }
            else
            {
                // Value is stored in the key
                ObjectManager om = sm.getObjectManager();
                PersistenceCapable pcNewKey = (PersistenceCapable)newKey;
                final Object newOwner = sm.getObject();

                if (om.getApiAdapter().isPersistent(pcNewKey))
                {
                    /*
 
View Full Code Here

        ObjectManager om = sm.getObjectManager();
       
        // Null out the key and owner fields if they are nullable
        if (keyMapping.isNullable())
        {
            PersistenceCapable pcOldValue = (PersistenceCapable)oldValue;
            StateManager vsm = om.findStateManager(pcOldValue);
           
            // Null the key field
            vsm.setObjectField(pcOldValue, keyFieldNumber, key, null);
            vsm.replaceField(keyFieldNumber, null, true);
View Full Code Here

        if (keyMapping.isNullable())
        {
            StateManager vsm = om.findStateManager(oldValue);

            // Check that the value hasn't already been deleted due to being removed from the map
            PersistenceCapable oldValuePC = (PersistenceCapable)oldValue;
            if (!om.getApiAdapter().isDeleted(oldValuePC))
            {
                // Null the key field
                vsm.setObjectField(oldValuePC, keyFieldNumber, key, null);
                vsm.replaceField(keyFieldNumber, null, true);
View Full Code Here

     */
    public void storeObjectField(int fieldNumber, Object value)
    {
        if (ec.getApiAdapter().isPersistable(value))
        {
            PersistenceCapable pc = (PersistenceCapable)value;
            // TODO Not checked this when we have compound identity and a sub-EmbeddedId
            pc.jdoCopyKeyFieldsFromObjectId(this, pc.jdoGetObjectId());
        }
        else
        {
            JavaTypeMapping mapping = javaTypeMappings[mappingNum++];
            mapping.setObject(ec, statement, getParamsForField(mapping), value);
View Full Code Here

     * on a persistent instance with its primary key field initialized,
     * @param o the object to check
     */
    private void singleFieldIdentityNotInitialized(AbstractPCPointSingleField o) {
        assertPersistenceCapable(o);
        PersistenceCapable pc = (PersistenceCapable) o;
        try {
            Object sfi = pc.jdoNewObjectIdInstance();
            String message = ASSERTION_A7_12_38_FAILED +
            "pc.jdoNewObjectIdInstance should throw " +
            "JDONullIdentityException if PK field is null, but it returned "+sfi;
            fail(message);
        } catch (JDONullIdentityException e) {
View Full Code Here

     * @param o the persistent instance to check
     */
    private void singleFieldIdentityInitialized(AbstractPCPointSingleField o) {
        assertPersistenceCapable(o);
        makePersistent(o);
        PersistenceCapable pc = (PersistenceCapable) o;
        SingleFieldIdentity sfi =
            (SingleFieldIdentity) pc.jdoNewObjectIdInstance();
        if (!o.equalsPKField(sfi)) {
            fail(ASSERTION_A7_12_39_FAILED +
                    "pc.jdoNewObjectIdInstance() returned unexpected " +
                    "single field identity object id.");
        }
View Full Code Here

     * @param o the object to check
     */
    private void singleFieldIdentity(AbstractPCPointSingleField o) {
        assertPersistenceCapable(o);
        SingleFieldIdentity sfi = (SingleFieldIdentity) makePersistent(o);
        PersistenceCapable pc = (PersistenceCapable) o;
        ObjectIdFieldConsumer objectIdFieldConsumer =
            new ObjectIdFieldConsumer();
        pc.jdoCopyKeyFieldsFromObjectId(objectIdFieldConsumer, sfi);
        if (!objectIdFieldConsumer.equals(sfi)) {
            fail(ASSERTION_FAILED +
                    "pc.jdoCopyKeyFieldsFromObjectId copies unexpected " +
                    "fields into an object id field consumer using a " +
                    "single field indentity object id.");
View Full Code Here

TOP

Related Classes of javax.jdo.spi.PersistenceCapable$ObjectIdFieldSupplier

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.