Package org.datanucleus.enhancer.methods
Class CopyKeyFieldsFromObjectId2
- java.lang.Object
-
- org.datanucleus.enhancer.ClassMethod
-
- org.datanucleus.enhancer.methods.CopyKeyFieldsFromObjectId2
-
public class CopyKeyFieldsFromObjectId2 extends ClassMethod
Method to generate the method "dnCopyKeyFieldsFromObjectId" using ASM. For datastore/nondurable identityprotected void dnCopyKeyFieldsFromObjectId(Object object) { }
and for SingleFieldIdentityprotected void dnCopyKeyFieldsFromObjectId(Object oid) { if (!(oid instanceof YYYIdentity)) throw new ClassCastException("key class is not YYYIdentity or null"); YYYIdentity o = (YYYIdentity) oid; id = o.getKey(); }
and for user-supplied app identityprotected void dnCopyKeyFieldsFromObjectId(Object oid) { if (!(oid instanceof UserPrimaryKey)) throw new ClassCastException("key class is not mydomain.UserPrimarKey or null"); UserPrimaryKey o = (UserPrimaryKey) oid; try { zzz1 = o.zzz1; zzz2 = o.zzz2; } catch(Exception e) {} }
and for CompoundIdentityprotected void dnCopyKeyFieldsFromObjectId(Object oid) { if (!(oid instanceof UserPrimaryKey)) throw new ClassCastException("key class is not mydomain.UserPrimarKey or null"); UserPrimaryKey o = (UserPrimaryKey) oid; try { zzz1 = o.zzz1; zzz2 = (ZZZ) this.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.- Version:
- $Revision: 1.21 $
-
-
Field Summary
-
Fields inherited from class org.datanucleus.enhancer.ClassMethod
access, argNames, argTypes, enhancer, exceptions, methodName, returnType, visitor
-
-
Constructor Summary
Constructors Constructor Description CopyKeyFieldsFromObjectId2(ClassEnhancer enhancer, String name, int access, Object returnType, Object[] argTypes, String[] argNames)
Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
execute()
Method to add the contents of the class method.static CopyKeyFieldsFromObjectId2
getInstance(ClassEnhancer enhancer)
-
Methods inherited from class org.datanucleus.enhancer.ClassMethod
close, equals, getAccess, getClassEnhancer, getDescriptor, getMethodAdditionMessage, getName, getNamer, hashCode, initialise, initialise
-
-
-
-
Constructor Detail
-
CopyKeyFieldsFromObjectId2
public CopyKeyFieldsFromObjectId2(ClassEnhancer enhancer, String name, int access, Object returnType, Object[] argTypes, String[] argNames)
Constructor.- Parameters:
enhancer
- ClassEnhancername
- Name of methodaccess
- Access typereturnType
- Return typeargTypes
- Argument typesargNames
- Argument names
-
-
Method Detail
-
getInstance
public static CopyKeyFieldsFromObjectId2 getInstance(ClassEnhancer enhancer)
-
execute
public void execute()
Method to add the contents of the class method.- Specified by:
execute
in classClassMethod
-
-