Class PrimaryKeyGenerator
java.lang.Object
org.datanucleus.enhancer.PrimaryKeyGenerator
Class to handle the generation of a PK class for a persistable class.
The primary key class is generated as its own class, rather than as an inner class of the original class.
NOTE: This will only currently handle persistable fields. If you require persistable properties then get the code and extend this.
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) final ClassEnhancerThe enhancer being used.(package private) final StringASM name of the PK class ("mydomain/MyClass_PK").(package private) final StringASM type descriptor name of the PK class ("Lmydomain/MyClass_PK;").(package private) final AbstractClassMetaDataMetadata for the class that needs a primary key class.(package private) final StringName of the primary key class ("mydomain.MyClass_PK").(package private) String -
Constructor Summary
ConstructorsConstructorDescriptionPrimaryKeyGenerator(AbstractClassMetaData cmd, ClassEnhancer enhancer) Constructor for a PK generator for the specified class. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidMethod to add an empty default constructor.protected voidaddFields(ClassWriter cw) Method to add fields to match the PK fields of the persistable classprotected voidMethod to add an equals() method.protected voidMethod to add a hashCode() method.protected voidMethod to add a toString() method.protected voidMethod to add a constructor taking in a String.byte[]generate()Method to generate the primary key class.protected String
-
Field Details
-
cmd
Metadata for the class that needs a primary key class. -
pkClassName
Name of the primary key class ("mydomain.MyClass_PK"). -
className_ASM
ASM name of the PK class ("mydomain/MyClass_PK"). -
className_DescName
ASM type descriptor name of the PK class ("Lmydomain/MyClass_PK;"). -
classEnhancer
The enhancer being used. -
stringSeparator
String stringSeparator
-
-
Constructor Details
-
PrimaryKeyGenerator
Constructor for a PK generator for the specified class.- Parameters:
cmd- Metadata for the class that needs a primary key classenhancer- The enhancer being used
-
-
Method Details
-
generate
public byte[] generate()Method to generate the primary key class.- Returns:
- The bytes for this pk class
-
addFields
Method to add fields to match the PK fields of the persistable class- Parameters:
cw- The ClassWriter to use
-
getTypeNameForField
-
addDefaultConstructor
Method to add an empty default constructor.- Parameters:
cw- The ClassWriter to use
-
addStringConstructor
Method to add a constructor taking in a String.- Parameters:
cw- The ClassWriter to use
-
addMethodToString
Method to add a toString() method.- Parameters:
cw- The ClassWriter to use
-
addMethodEquals
Method to add an equals() method.- Parameters:
cw- The ClassWriter to use
-
addMethodHashCode
Method to add a hashCode() method.- Parameters:
cw- The ClassWriter to use
-