/** * Create a new ObjectId instance and copy the key fields from the * persistence capable instance to the objectId instance * @param pc The persistence capable object * @param cmd The AbstractClassMetaData * @return The object id for the persistence capable object */ public static Object getNewObjectId(PersistenceCapable pc, AbstractClassMetaData cmd) { Object userOid = pc.jdoNewObjectIdInstance(); if (!cmd.usesSingleFieldIdentityClass()) { pc.jdoCopyKeyFieldsToObjectId(userOid); } return userOid; }
/** * Method to create a new object identity for the passed object with the supplied MetaData. * Only applies to application-identity cases. * @param pc The persistable object * @param cmd Its metadata * @return The new identity object */ public Object getNewApplicationIdentityObjectId(Object pc, AbstractClassMetaData cmd) { if (pc == null || cmd == null) { return null; } // TODO Change this to Persistable Object id = ((PersistenceCapable)pc).jdoNewObjectIdInstance(); if (!cmd.usesSingleFieldIdentityClass()) { ((PersistenceCapable)pc).jdoCopyKeyFieldsToObjectId(id); } return id; }
/** * Method to create a new object identity for the passed object with the supplied MetaData. * Only applies to application-identity cases. * @param pc The persistable object * @param cmd Its metadata * @return The new identity object */ public Object getNewApplicationIdentityObjectId(Object pc, AbstractClassMetaData cmd) { if (pc == null || cmd == null) { return null; } // TODO Change this to Persistable Object id = ((PersistenceCapable)pc).jdoNewObjectIdInstance(); if (!cmd.usesSingleFieldIdentityClass()) { ((PersistenceCapable)pc).jdoCopyKeyFieldsToObjectId(id); } return id; }
/** Copy fields from an outside source to 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. * <P>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 jdoCopyKeyFieldsToObjectId (Object oid, ObjectIdFieldSupplier fm) { * <BR> oid.id = fm.fetchIntField (0); * <BR> oid.name = fm.fetchStringField (1); * <BR> oid.salary = fm.fetchObjectField (2); * <BR>}</code> * <P>The implementation is responsible for implementing the * <code>ObjectIdFieldSupplier</code> to provide the values for the key * fields. * @param pcClass the <code>PersistenceCapable Class</code>. * @param oid the ObjectId target of the copy. * @param fm the field manager that supplies the field values. */ public void copyKeyFieldsToObjectId (Class pcClass, PersistenceCapable.ObjectIdFieldSupplier 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.jdoCopyKeyFieldsToObjectId(fm, oid); }
/** Copy fields from an outside source to 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. * <P>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 jdoCopyKeyFieldsToObjectId (Object oid, ObjectIdFieldSupplier fm) { * <BR> oid.id = fm.fetchIntField (0); * <BR> oid.name = fm.fetchStringField (1); * <BR> oid.salary = fm.fetchObjectField (2); * <BR>}</code> * <P>The implementation is responsible for implementing the * <code>ObjectIdFieldSupplier</code> to provide the values for the key * fields. * @param pcClass the <code>PersistenceCapable Class</code>. * @param oid the ObjectId target of the copy. * @param fm the field manager that supplies the field values. */ public void copyKeyFieldsToObjectId (Class pcClass, PersistenceCapable.ObjectIdFieldSupplier 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.jdoCopyKeyFieldsToObjectId(fm, oid); }
if (!cmd.usesSingleFieldIdentityClass()) myPC.jdoCopyKeyFieldsToObjectId(myID);
if (!cmd.usesSingleFieldIdentityClass()) myPC.jdoCopyKeyFieldsToObjectId(myID);