Class RecordPersistenceCapable
java.lang.Object
org.apache.openjpa.enhance.RecordPersistenceCapable
- All Implemented Interfaces:
ManagedInstanceProvider, PersistenceCapable
public class RecordPersistenceCapable
extends Object
implements PersistenceCapable, ManagedInstanceProvider
Implementation of
PersistenceCapable for Java record types.
Records cannot be enhanced (they are final), so this class provides
the PersistenceCapable contract using an internal value array and
the record's canonical constructor for materialization.
JPA 3.2 allows records as embeddable classes. During loading, field values are collected in an internal array. When the managed instance is requested, the record is constructed via its canonical constructor.
- Since:
- 4.2.0
-
Field Summary
Fields inherited from interface PersistenceCapable
CHECK_READ, CHECK_WRITE, DESERIALIZED, LOAD_REQUIRED, MEDIATE_READ, MEDIATE_WRITE, READ_OK, READ_WRITE_OK, SERIALIZABLE -
Constructor Summary
ConstructorsConstructorDescriptionRecordPersistenceCapable(Class<?> recordClass, ClassMetaData meta) Prototype constructor used for PCRegistry registration.RecordPersistenceCapable(Class<?> recordClass, ClassMetaData meta, Object recordInstance) Instance constructor wrapping an existing record (for persistence). -
Method Summary
Modifier and TypeMethodDescriptionConstructs the actual record instance from accumulated field values.voidpcCopyFields(Object fromObject, int[] fieldIndices) voidpcCopyKeyFieldsFromObjectId(FieldConsumer consumer, Object obj) voidvoidpcCopyKeyFieldsToObjectId(FieldSupplier supplier, Object obj) voidintbooleanbooleanbooleanpcIsNew()booleanbooleanpcNewInstance(StateManager sm, boolean clear) pcNewInstance(StateManager sm, Object oid, boolean clear) voidpcProvideField(int i) voidpcProvideFields(int[] fieldIndices) voidpcReplaceField(int i) voidpcReplaceFields(int[] fieldIndices) voidvoidpcSetDetachedState(Object state) static voidregisterRecordType(Class<?> recordClass, ClassMetaData meta) Registers the given record class with PCRegistry so that the standard embedding machinery can work with it.voidrematerialize(OpenJPAStateManager stateMgr) Re-reads field values from the given StateManager and constructs a fresh record instance.
-
Constructor Details
-
RecordPersistenceCapable
Prototype constructor used for PCRegistry registration. -
RecordPersistenceCapable
Instance constructor wrapping an existing record (for persistence).
-
-
Method Details
-
materialize
Constructs the actual record instance from accumulated field values. Maps field metadata indices to canonical constructor parameter positions based on record component order. -
rematerialize
Re-reads field values from the given StateManager and constructs a fresh record instance. Used after attach/merge where field values are stored in the SM rather than in this wrapper's fieldValues array. -
pcGetEnhancementContractVersion
public int pcGetEnhancementContractVersion()- Specified by:
pcGetEnhancementContractVersionin interfacePersistenceCapable
-
pcGetGenericContext
- Specified by:
pcGetGenericContextin interfacePersistenceCapable
-
pcGetStateManager
- Specified by:
pcGetStateManagerin interfacePersistenceCapable
-
pcReplaceStateManager
- Specified by:
pcReplaceStateManagerin interfacePersistenceCapable
-
pcProvideField
public void pcProvideField(int i) - Specified by:
pcProvideFieldin interfacePersistenceCapable
-
pcProvideFields
public void pcProvideFields(int[] fieldIndices) - Specified by:
pcProvideFieldsin interfacePersistenceCapable
-
pcReplaceField
public void pcReplaceField(int i) - Specified by:
pcReplaceFieldin interfacePersistenceCapable
-
pcReplaceFields
public void pcReplaceFields(int[] fieldIndices) - Specified by:
pcReplaceFieldsin interfacePersistenceCapable
-
pcCopyFields
- Specified by:
pcCopyFieldsin interfacePersistenceCapable
-
pcDirty
- Specified by:
pcDirtyin interfacePersistenceCapable
-
pcFetchObjectId
- Specified by:
pcFetchObjectIdin interfacePersistenceCapable
-
pcGetVersion
- Specified by:
pcGetVersionin interfacePersistenceCapable
-
pcIsDirty
public boolean pcIsDirty()- Specified by:
pcIsDirtyin interfacePersistenceCapable
-
pcIsTransactional
public boolean pcIsTransactional()- Specified by:
pcIsTransactionalin interfacePersistenceCapable
-
pcIsPersistent
public boolean pcIsPersistent()- Specified by:
pcIsPersistentin interfacePersistenceCapable
-
pcIsNew
public boolean pcIsNew()- Specified by:
pcIsNewin interfacePersistenceCapable
-
pcIsDeleted
public boolean pcIsDeleted()- Specified by:
pcIsDeletedin interfacePersistenceCapable
-
pcIsDetached
- Specified by:
pcIsDetachedin interfacePersistenceCapable
-
pcNewInstance
- Specified by:
pcNewInstancein interfacePersistenceCapable
-
pcNewInstance
- Specified by:
pcNewInstancein interfacePersistenceCapable
-
pcNewObjectIdInstance
- Specified by:
pcNewObjectIdInstancein interfacePersistenceCapable
-
pcNewObjectIdInstance
- Specified by:
pcNewObjectIdInstancein interfacePersistenceCapable
-
pcCopyKeyFieldsToObjectId
- Specified by:
pcCopyKeyFieldsToObjectIdin interfacePersistenceCapable
-
pcCopyKeyFieldsToObjectId
- Specified by:
pcCopyKeyFieldsToObjectIdin interfacePersistenceCapable
-
pcCopyKeyFieldsFromObjectId
- Specified by:
pcCopyKeyFieldsFromObjectIdin interfacePersistenceCapable
-
pcGetDetachedState
- Specified by:
pcGetDetachedStatein interfacePersistenceCapable
-
pcSetDetachedState
- Specified by:
pcSetDetachedStatein interfacePersistenceCapable
-
getManagedInstance
- Specified by:
getManagedInstancein interfaceManagedInstanceProvider
-
registerRecordType
Registers the given record class with PCRegistry so that the standard embedding machinery can work with it.
-