/** * Method to store an object in a field. * @param fieldNumber Number of the field * @param value The value to use */ public void storeObjectField(int fieldNumber, Object value) { if (value instanceof PersistenceCapable) { PersistenceCapable pc = (PersistenceCapable)value; pc.jdoCopyKeyFieldsFromObjectId(this, pc.jdoGetObjectId()); } else { JavaTypeMapping mapping = javaTypeMappings[mappingNum++]; mapping.setObject(pm, statement, getParamsForField(mapping), value); } } }
/** Copy fields to an outside source from the key fields in the ObjectId. * This method is generated in the <code>PersistenceCapable</code> class to * generate a call to the field manager for each key field in the ObjectId. * For example, an ObjectId class that has three key fields * (<code>int id</code>, <code>String name</code>, and * <code>Float salary</code>) would have the method generated: * <P><code>void jdoCopyKeyFieldsFromObjectId * <BR> (PersistenceCapable oid, ObjectIdFieldConsumer fm) { * <BR> fm.storeIntField (0, oid.id); * <BR> fm.storeStringField (1, oid.name); * <BR> fm.storeObjectField (2, oid.salary); * <BR>}</code> * <P>The implementation is responsible for implementing the * <code>ObjectIdFieldConsumer</code> to store the values for the key * fields. * @param pcClass the <code>PersistenceCapable</code> class * @param oid the ObjectId source of the copy. * @param fm the field manager that receives the field values. */ public void copyKeyFieldsFromObjectId (Class pcClass, PersistenceCapable.ObjectIdFieldConsumer fm, Object oid) { Meta meta = getMeta (pcClass); PersistenceCapable pcInstance = meta.getPC(); if (pcInstance == null) { throw new JDOFatalInternalException (msg.msg( "ERR_AbstractClassNoIdentity", pcClass.getName())); //NOI18N } pcInstance.jdoCopyKeyFieldsFromObjectId(fm, oid); }
/** Copy fields to an outside source from the key fields in the ObjectId. * This method is generated in the <code>PersistenceCapable</code> class to * generate a call to the field manager for each key field in the ObjectId. * For example, an ObjectId class that has three key fields * (<code>int id</code>, <code>String name</code>, and * <code>Float salary</code>) would have the method generated: * <P><code>void jdoCopyKeyFieldsFromObjectId * <BR> (PersistenceCapable oid, ObjectIdFieldConsumer fm) { * <BR> fm.storeIntField (0, oid.id); * <BR> fm.storeStringField (1, oid.name); * <BR> fm.storeObjectField (2, oid.salary); * <BR>}</code> * <P>The implementation is responsible for implementing the * <code>ObjectIdFieldConsumer</code> to store the values for the key * fields. * @param pcClass the <code>PersistenceCapable</code> class * @param oid the ObjectId source of the copy. * @param fm the field manager that receives the field values. */ public void copyKeyFieldsFromObjectId (Class pcClass, PersistenceCapable.ObjectIdFieldConsumer fm, Object oid) { Meta meta = getMeta (pcClass); PersistenceCapable pcInstance = meta.getPC(); if (pcInstance == null) { throw new JDOFatalInternalException (msg.msg( "ERR_AbstractClassNoIdentity", pcClass.getName())); //NOI18N } pcInstance.jdoCopyKeyFieldsFromObjectId(fm, oid); }
pc.jdoCopyKeyFieldsFromObjectId(new AppIDObjectIdFieldConsumer(param, pm, ps, javaTypeMappings), id);