- java.lang.Object
-
- org.datanucleus.enhancer.PrimaryKeyGenerator
-
public class PrimaryKeyGenerator extends Object
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.
-
-
Constructor Summary
Constructors Constructor Description PrimaryKeyGenerator(AbstractClassMetaData cmd, ClassEnhancer enhancer)
Constructor for a PK generator for the specified class.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addDefaultConstructor(ClassWriter cw)
Method to add an empty default constructor.protected void
addFields(ClassWriter cw)
Method to add fields to match the PK fields of the persistable classprotected void
addMethodEquals(ClassWriter cw)
Method to add an equals() method.protected void
addMethodHashCode(ClassWriter cw)
Method to add a hashCode() method.protected void
addMethodToString(ClassWriter cw)
Method to add a toString() method.protected void
addStringConstructor(ClassWriter cw)
Method to add a constructor taking in a String.byte[]
generate()
Method to generate the primary key class.protected String
getTypeNameForField(AbstractMemberMetaData mmd)
-
-
-
Constructor Detail
-
PrimaryKeyGenerator
public PrimaryKeyGenerator(AbstractClassMetaData cmd, ClassEnhancer enhancer)
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 Detail
-
generate
public byte[] generate()
Method to generate the primary key class.- Returns:
- The bytes for this pk class
-
addFields
protected void addFields(ClassWriter cw)
Method to add fields to match the PK fields of the persistable class- Parameters:
cw
- The ClassWriter to use
-
getTypeNameForField
protected String getTypeNameForField(AbstractMemberMetaData mmd)
-
addDefaultConstructor
protected void addDefaultConstructor(ClassWriter cw)
Method to add an empty default constructor.- Parameters:
cw
- The ClassWriter to use
-
addStringConstructor
protected void addStringConstructor(ClassWriter cw)
Method to add a constructor taking in a String.- Parameters:
cw
- The ClassWriter to use
-
addMethodToString
protected void addMethodToString(ClassWriter cw)
Method to add a toString() method.- Parameters:
cw
- The ClassWriter to use
-
addMethodEquals
protected void addMethodEquals(ClassWriter cw)
Method to add an equals() method.- Parameters:
cw
- The ClassWriter to use
-
addMethodHashCode
protected void addMethodHashCode(ClassWriter cw)
Method to add a hashCode() method.- Parameters:
cw
- The ClassWriter to use
-
-