Class ReturningPolicy
java.lang.Object
org.eclipse.persistence.descriptors.ReturningPolicy
- All Implemented Interfaces:
Serializable
,Cloneable
Purpose: Allows for INSERT or UPDATE operations to return values back into the object being written. This allows for table default values, trigger or stored procedures computed values to be set back into the object. This can be used with generated SQL on the Oracle platform using the RETURNING clause, or through stored procedures on other platforms.
- See Also:
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionprotected static final int
protected ClassDescriptor
owner of the policyprotected Map<org.eclipse.persistence.internal.helper.DatabaseField,
org.eclipse.persistence.internal.helper.DatabaseField> contains all default table the returning fields that are either unmapped or mapped supplied with types.protected Map<org.eclipse.persistence.internal.helper.DatabaseField,
org.eclipse.persistence.internal.helper.DatabaseField> contains all the other tables returning fields that are either unmapped or mapped supplied with types.protected List<ReturningPolicy.Info>
Stores an object of type Info for every call to any of addField..protected static final int
protected boolean
indicates whether ReturningPolicy is used for generation of the PK.protected Collection<org.eclipse.persistence.internal.helper.DatabaseField>[][]
The following attributes are initialized by initialize() method.protected static final int
protected static final int
protected static final int
protected static final int
protected Map<org.eclipse.persistence.internal.helper.DatabaseTable,
Vector<org.eclipse.persistence.internal.helper.DatabaseField>>[] maps ClassDescriptor's tables into Vectors of fields to be used for call generation.protected static final int
protected static final int
protected static final int
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
addCollectionToMain
(int operation, int state, Collection collection) protected void
addField
(org.eclipse.persistence.internal.helper.DatabaseField field, boolean isInsert, boolean isInsertModeReturnOnly, boolean isUpdate) INTERNAL:void
addFieldForInsert
(String qualifiedName) PUBLIC: Define that the field will be returned from an insert operation.void
addFieldForInsert
(String qualifiedName, Class type) PUBLIC: Define that the field will be returned from an insert operation.void
addFieldForInsert
(org.eclipse.persistence.internal.helper.DatabaseField field) PUBLIC: Define that the field will be returned from an insert operation.void
addFieldForInsertReturnOnly
(String qualifiedName) PUBLIC: Define that the field will be returned from an insert operation.void
addFieldForInsertReturnOnly
(String qualifiedName, Class type) PUBLIC: Define that the field will be returned from an insert operation.void
addFieldForInsertReturnOnly
(org.eclipse.persistence.internal.helper.DatabaseField field) PUBLIC: Define that the field will be returned from an insert operation.void
addFieldForUpdate
(String qualifiedName) PUBLIC: Define that the field will be returned from an update operation.void
addFieldForUpdate
(String qualifiedName, Class type) PUBLIC: Define that the field will be returned from an update operation.void
addFieldForUpdate
(org.eclipse.persistence.internal.helper.DatabaseField field) PUBLIC: Define that the field will be returned from an update operation.protected void
addFieldToMain
(int operation, int state, org.eclipse.persistence.internal.helper.DatabaseField field) protected void
addMappedFieldToMain
(org.eclipse.persistence.internal.helper.DatabaseField field, ReturningPolicy.Info info) protected void
addUnmappedFieldToMain
(org.eclipse.persistence.internal.helper.DatabaseField field, ReturningPolicy.Info info) static boolean
areCollectionsEqualAsSets
(Collection col1, Collection col2) INTERNAL: Compares two Collections as sets (ignoring the order of the elements).protected void
clone()
INTERNAL: Normally cloned when not yet initialized.protected void
copyMainFrom
(ReturningPolicy policy) protected Collection
INTERNAL:protected org.eclipse.persistence.internal.helper.DatabaseField
createField
(String qualifiedName, Class type) INTERNAL:protected void
fieldIsNotFromDescriptor
(org.eclipse.persistence.internal.helper.DatabaseField field) INTERNAL:PUBLIC: Return the owner of the policy.org.eclipse.persistence.internal.helper.DatabaseField
getField
(org.eclipse.persistence.internal.helper.DatabaseField field) INTERNAL: Returns an equal field held by ReturningPolicy, or null.INTERNAL:getFieldsToGenerateInsert
(org.eclipse.persistence.internal.helper.DatabaseTable table) INTERNAL:getFieldsToGenerateUpdate
(org.eclipse.persistence.internal.helper.DatabaseTable table) INTERNAL:Collection<org.eclipse.persistence.internal.helper.DatabaseField>
INTERNAL:Collection<org.eclipse.persistence.internal.helper.DatabaseField>
INTERNAL:protected Vector<org.eclipse.persistence.internal.helper.DatabaseField>
getVectorOfFieldsToGenerate
(int operation, org.eclipse.persistence.internal.helper.DatabaseTable table) INTERNAL:boolean
hasEqualFieldInfos
(List<ReturningPolicy.Info> infosToCompare) INTERNAL: Used for testing onlyboolean
hasEqualFieldInfos
(ReturningPolicy returningPolicyToCompare) INTERNAL: Used for testing onlyboolean
hasEqualMains
(ReturningPolicy policy) INTERNAL: Both ReturningPolicies should be initializedvoid
initialize
(org.eclipse.persistence.internal.sessions.AbstractSession session) INTERNAL:protected void
protected static boolean
isThereATypeConflict
(org.eclipse.persistence.internal.helper.DatabaseField field1, org.eclipse.persistence.internal.helper.DatabaseField field2) INTERNAL:boolean
PUBLIC:protected Hashtable
removeDuplicateAndValidateInfos
(org.eclipse.persistence.internal.sessions.AbstractSession session) void
setDescriptor
(ClassDescriptor descriptor) INTERNAL:void
setFieldInfos
(List<ReturningPolicy.Info> infos) INTERNAL:protected void
trimModifyRow
(org.eclipse.persistence.internal.sessions.AbstractRecord modifyRow, int operation) void
trimModifyRowForInsert
(org.eclipse.persistence.internal.sessions.AbstractRecord modifyRow) INTERNAL:void
validationAfterDescriptorInitialization
(org.eclipse.persistence.internal.sessions.AbstractSession session) INTERNAL:protected static boolean
verifyField
(org.eclipse.persistence.internal.sessions.AbstractSession session, org.eclipse.persistence.internal.helper.DatabaseField field, ClassDescriptor descriptor) protected boolean
verifyFieldAndMapping
(org.eclipse.persistence.internal.sessions.AbstractSession session, org.eclipse.persistence.internal.helper.DatabaseField field) protected static boolean
verifyFieldAndMapping
(org.eclipse.persistence.internal.sessions.AbstractSession session, org.eclipse.persistence.internal.helper.DatabaseField field, ClassDescriptor descriptor, DatabaseMapping mapping)
-
Field Details
-
INSERT
protected static final int INSERT- See Also:
-
UPDATE
protected static final int UPDATE- See Also:
-
NUM_OPERATIONS
protected static final int NUM_OPERATIONS- See Also:
-
RETURN_ONLY
protected static final int RETURN_ONLY- See Also:
-
WRITE_RETURN
protected static final int WRITE_RETURN- See Also:
-
MAPPED
protected static final int MAPPED- See Also:
-
UNMAPPED
protected static final int UNMAPPED- See Also:
-
ALL
protected static final int ALL- See Also:
-
MAIN_SIZE
protected static final int MAIN_SIZE- See Also:
-
descriptor
owner of the policy -
infos
Stores an object of type Info for every call to any of addField.. methods. Should be filled out before initialize() is called: fields added after initialization are ignored. -
main
The following attributes are initialized by initialize() method. Contains the actual DatabaseFields to be returned. Populated during descriptor initialization using infos. Here's the order:main[INSERT][RETURN_ONLY] main[INSERT][WRITE_RETURN] main[INSERT][MAPPED] main[INSERT][UNMAPPED] main[INSERT][ALL] main[UPDATE][RETURN_ONLY] main[UPDATE][WRITE_RETURN] main[UPDATE][MAPPED] main[UPDATE][UNMAPPED] main[UPDATE][ALL]
After initialization main[UPDATE,WRITE_RETURN] will contain all DatabaseFields that should be returned on Update as read-write.main[i][RETURN_ONLY] + main[i][WRITE_RETURN] = main[i][MAPPED] main[i][MAPPED] + main[i][UNMAPPED] = main[i][ALL]
-
tableToFieldsForGenerationMap
protected Map<org.eclipse.persistence.internal.helper.DatabaseTable,Vector<org.eclipse.persistence.internal.helper.DatabaseField>>[] tableToFieldsForGenerationMapmaps ClassDescriptor's tables into Vectors of fields to be used for call generation. Lazily initialized array [NUM_OPERATIONS] -
isUsedToSetPrimaryKey
protected boolean isUsedToSetPrimaryKeyindicates whether ReturningPolicy is used for generation of the PK. -
fieldsNotFromDescriptor_DefaultTable
protected Map<org.eclipse.persistence.internal.helper.DatabaseField,org.eclipse.persistence.internal.helper.DatabaseField> fieldsNotFromDescriptor_DefaultTablecontains all default table the returning fields that are either unmapped or mapped supplied with types. -
fieldsNotFromDescriptor_OtherTables
protected Map<org.eclipse.persistence.internal.helper.DatabaseField,org.eclipse.persistence.internal.helper.DatabaseField> fieldsNotFromDescriptor_OtherTablescontains all the other tables returning fields that are either unmapped or mapped supplied with types.
-
-
Constructor Details
-
ReturningPolicy
public ReturningPolicy()
-
-
Method Details
-
getDescriptor
PUBLIC: Return the owner of the policy. -
fieldIsNotFromDescriptor
protected void fieldIsNotFromDescriptor(org.eclipse.persistence.internal.helper.DatabaseField field) INTERNAL: -
getFieldsToGenerateInsert
public Vector getFieldsToGenerateInsert(org.eclipse.persistence.internal.helper.DatabaseTable table) INTERNAL: -
getFieldsToGenerateUpdate
public Vector getFieldsToGenerateUpdate(org.eclipse.persistence.internal.helper.DatabaseTable table) INTERNAL: -
getFieldInfos
INTERNAL: -
setFieldInfos
INTERNAL: -
hasEqualFieldInfos
INTERNAL: Used for testing only -
hasEqualFieldInfos
INTERNAL: Used for testing only -
areCollectionsEqualAsSets
INTERNAL: Compares two Collections as sets (ignoring the order of the elements). Note that the passed Collections are cloned. Used for testing only. -
getVectorOfFieldsToGenerate
protected Vector<org.eclipse.persistence.internal.helper.DatabaseField> getVectorOfFieldsToGenerate(int operation, org.eclipse.persistence.internal.helper.DatabaseTable table) INTERNAL: -
getFieldsToMergeInsert
INTERNAL: -
getFieldsToMergeUpdate
INTERNAL: -
clone
INTERNAL: Normally cloned when not yet initialized. If initialized ReturningPolicy cloned then the clone should be re-initialized. -
setDescriptor
INTERNAL: -
addFieldForInsert
PUBLIC: Define that the field will be returned from an insert operation. -
addFieldForInsert
PUBLIC: Define that the field will be returned from an insert operation. The type may be required to bind the output parameter if not known by the mapping. -
addFieldForInsert
public void addFieldForInsert(org.eclipse.persistence.internal.helper.DatabaseField field) PUBLIC: Define that the field will be returned from an insert operation. -
addFieldForInsertReturnOnly
PUBLIC: Define that the field will be returned from an insert operation. A field added with addFieldForInsertReturnOnly method is excluded from INSERT clause during SQL generation. -
addFieldForInsertReturnOnly
PUBLIC: Define that the field will be returned from an insert operation. A field added with addFieldForInsertReturnOnly method is excluded from INSERT clause during SQL generation. The type may be required to bind the output parameter if not known by the mapping. -
addFieldForInsertReturnOnly
public void addFieldForInsertReturnOnly(org.eclipse.persistence.internal.helper.DatabaseField field) PUBLIC: Define that the field will be returned from an insert operation. A field added with addFieldForInsertReturnOnly method is excluded from INSERT clause during SQL generation. -
addFieldForUpdate
PUBLIC: Define that the field will be returned from an update operation. -
addFieldForUpdate
PUBLIC: Define that the field will be returned from an update operation. The type may be required to bind the output parameter if not known by the mapping. -
addFieldForUpdate
public void addFieldForUpdate(org.eclipse.persistence.internal.helper.DatabaseField field) PUBLIC: Define that the field will be returned from an update operation. -
addField
protected void addField(org.eclipse.persistence.internal.helper.DatabaseField field, boolean isInsert, boolean isInsertModeReturnOnly, boolean isUpdate) INTERNAL: -
isThereATypeConflict
protected static boolean isThereATypeConflict(org.eclipse.persistence.internal.helper.DatabaseField field1, org.eclipse.persistence.internal.helper.DatabaseField field2) INTERNAL: -
createField
protected org.eclipse.persistence.internal.helper.DatabaseField createField(String qualifiedName, Class type) INTERNAL: -
createCollection
INTERNAL: -
addFieldToMain
protected void addFieldToMain(int operation, int state, org.eclipse.persistence.internal.helper.DatabaseField field) -
addCollectionToMain
-
addMappedFieldToMain
protected void addMappedFieldToMain(org.eclipse.persistence.internal.helper.DatabaseField field, ReturningPolicy.Info info) -
addUnmappedFieldToMain
protected void addUnmappedFieldToMain(org.eclipse.persistence.internal.helper.DatabaseField field, ReturningPolicy.Info info) -
removeDuplicateAndValidateInfos
protected Hashtable removeDuplicateAndValidateInfos(org.eclipse.persistence.internal.sessions.AbstractSession session) -
initialize
public void initialize(org.eclipse.persistence.internal.sessions.AbstractSession session) INTERNAL: -
copyMainFrom
-
hasEqualMains
INTERNAL: Both ReturningPolicies should be initialized -
trimModifyRowForInsert
public void trimModifyRowForInsert(org.eclipse.persistence.internal.sessions.AbstractRecord modifyRow) INTERNAL: -
trimModifyRow
protected void trimModifyRow(org.eclipse.persistence.internal.sessions.AbstractRecord modifyRow, int operation) -
isUsedToSetPrimaryKey
public boolean isUsedToSetPrimaryKey()PUBLIC: -
clearInitialization
protected void clearInitialization() -
initializeIsUsedToSetPrimaryKey
protected void initializeIsUsedToSetPrimaryKey() -
verifyFieldAndMapping
protected boolean verifyFieldAndMapping(org.eclipse.persistence.internal.sessions.AbstractSession session, org.eclipse.persistence.internal.helper.DatabaseField field) -
verifyFieldAndMapping
protected static boolean verifyFieldAndMapping(org.eclipse.persistence.internal.sessions.AbstractSession session, org.eclipse.persistence.internal.helper.DatabaseField field, ClassDescriptor descriptor, DatabaseMapping mapping) -
verifyField
protected static boolean verifyField(org.eclipse.persistence.internal.sessions.AbstractSession session, org.eclipse.persistence.internal.helper.DatabaseField field, ClassDescriptor descriptor) -
validationAfterDescriptorInitialization
public void validationAfterDescriptorInitialization(org.eclipse.persistence.internal.sessions.AbstractSession session) INTERNAL: -
getField
public org.eclipse.persistence.internal.helper.DatabaseField getField(org.eclipse.persistence.internal.helper.DatabaseField field) INTERNAL: Returns an equal field held by ReturningPolicy, or null.
-