public class CopyKeyFieldsFromObjectId extends ClassMethod
public void dnCopyKeyFieldsFromObjectId(Persistable.ObjectIdFieldConsumer fc, Object oid) { }and for SingleFieldIdentity it is
public void dnCopyKeyFieldsFromObjectId(Persistable.ObjectIdFieldConsumer fc, Object oid) { if (fc == null) throw new IllegalArgumentException("ObjectIdFieldConsumer is null"); if (!(oid instanceof YYYIdentity)) throw new ClassCastException("oid is not instanceof YYYIdentity"); YYYIdentity o = (YYYIdentity) oid; fc.storeYYYField(1, o.getKey()); }and for user-defined primary keys
public void dnCopyKeyFieldsFromObjectId(Persistable.ObjectIdFieldConsumer fc, Object oid) { if (fc == null) throw new IllegalArgumentException("ObjectIdFieldConsumer is null"); if (!(oid instanceof UserPrimaryKey)) throw new ClassCastException("oid is not instanceof mydomain.UserPrimaryKey"); UserPrimaryKey o = (UserPrimaryKey) oid; try { fc.storeYYYField(1, o.id); fc.storeZZZField(2, o.name); } catch(Exception e) {} }and for CompoundIdentity
public void dnCopyKeyFieldsFromObjectId(Persistable.ObjectIdFieldConsumer fc, Object oid) { if (fc == null) throw new IllegalArgumentException("ObjectIdFieldConsumer is null"); if (!(oid instanceof UserPrimaryKey)) throw new ClassCastException("oid is not instanceof mydomain.UserPrimaryKey"); UserPrimaryKey o = (UserPrimaryKey) oid; try { fc.storeYYYField(1, o.id); fc.storeZZZField(2, dnGetPersistenceManager().getObjectById(o.zzz, false)); } catch (Exception e) {} }(the try-catch is for cases where we set the fields with reflection and it can throw an exception). There are some differences for fields .v. properties and also if fields in the PK are private.
access, argNames, argTypes, enhancer, exceptions, methodName, returnType, visitor
Constructor and Description |
---|
CopyKeyFieldsFromObjectId(ClassEnhancer enhancer,
String name,
int access,
Object returnType,
Object[] argTypes,
String[] argNames)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
execute()
Method to add the contents of the class method.
|
static CopyKeyFieldsFromObjectId |
getInstance(ClassEnhancer enhancer) |
close, equals, getAccess, getClassEnhancer, getDescriptor, getMethodAdditionMessage, getName, getNamer, hashCode, initialise, initialise
public CopyKeyFieldsFromObjectId(ClassEnhancer enhancer, String name, int access, Object returnType, Object[] argTypes, String[] argNames)
enhancer
- ClassEnhancername
- Name of methodaccess
- Access typereturnType
- Return typeargTypes
- Argument typesargNames
- Argument namespublic static CopyKeyFieldsFromObjectId getInstance(ClassEnhancer enhancer)
public void execute()
execute
in class ClassMethod
Copyright © 2019. All rights reserved.