Oracle Fusion Middleware Java API Reference for Oracle TopLink (Deprecated)
11g Release 1 (11.1.1)

B32476-04

oracle.toplink.history
Class HistoryPolicy

java.lang.Object
  extended by oracle.toplink.history.HistoryPolicy
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable

public class HistoryPolicy
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable

Purpose:Expresses how historical data is saved on the data store.

This information is used to both maintain a history of all objects modified through TopLink and to enable point in time querying.

If Oracle 9R2 or later Flashback is used this policy is not required, as the preservation of history is automatic.

Descriptors, ManyToManyMappings, DirectCollectionMappings, and DirectMapMappings only can have a history policy, as only they have associated database tables.

Since:
10
See Also:
Serialized Form

Constructor Summary
HistoryPolicy()
           
 
Method Summary
 void addEndFieldName(java.lang.String endFieldName)
          
 void addHistoryTableName(java.lang.String name)
          Use to specify the names of the mirroring historical tables.
 void addHistoryTableName(java.lang.String sourceTableName, java.lang.String historyTableName)
          Use to specify the names of the mirroring historical tables.
 void addStartFieldName(java.lang.String startFieldName)
          Sets the name of the start field.
 java.lang.Object clone()
          Performs a sufficiently deep clone.
 java.lang.Object getCurrentTime(oracle.toplink.internal.sessions.AbstractSession session)
          Whenever a historical record is logically deleted (updated) or inserted, the end and start fields respectively will be set to this value.
 ClassDescriptor getDescriptor()
          Return the descriptor of the policy.
 java.lang.String getEndFieldName()
          
 java.util.Vector getHistoryTableNames()
          
 DatabaseMapping getMapping()
          
 java.lang.String getStartFieldName()
          Answers the name of the start field.
 void setDescriptor(ClassDescriptor descriptor)
          
 void setEndFieldType(java.lang.String fieldName, java.lang.Class type)
          ADVANCED:
 void setShouldHandleWrites(boolean value)
          Sets if TopLink is responsible for writing history.
 void setShouldUseDatabaseTime(boolean value)
          Sets if the Timestamp used in maintainaing history should be the current time according to the database.
 void setStartFieldType(java.lang.Class type)
          ADVANCED: Sets the type of all start fields.
 boolean shouldHandleWrites()
          Answers if TopLink is responsible for writing history.
 boolean shouldUseDatabaseTime()
          Answers if the Timestamp used in maintaining history should be the current time according to the database.
 boolean shouldUseLocalTime()
          Answers if the Timestamp used in maintaining history should be System.currentTimeMillis();
 void useDatabaseTime()
          Answers if the Timestamp used in maintaining history should be the current time according to the database.
 void useLocalTime()
          Answers if the Timestamp used in maintaining history should be System.currentTimeMillis();
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HistoryPolicy

public HistoryPolicy()
Method Detail

clone

public java.lang.Object clone()
Performs a sufficiently deep clone. Use to quickly setup standard policies on multiple descriptors.

Overrides:
clone in class java.lang.Object

getCurrentTime

public java.lang.Object getCurrentTime(oracle.toplink.internal.sessions.AbstractSession session)
Whenever a historical record is logically deleted (updated) or inserted, the end and start fields respectively will be set to this value.


getDescriptor

public ClassDescriptor getDescriptor()
Return the descriptor of the policy.


getHistoryTableNames

public java.util.Vector getHistoryTableNames()


getMapping

public DatabaseMapping getMapping()


getStartFieldName

public java.lang.String getStartFieldName()
Answers the name of the start field. Assumes that multiple tables for a descriptor have the same field names.


getEndFieldName

public java.lang.String getEndFieldName()


setDescriptor

public void setDescriptor(ClassDescriptor descriptor)


addHistoryTableName

public void addHistoryTableName(java.lang.String name)
Use to specify the names of the mirroring historical tables.

Assumes that the order in which tables are added with descriptor.addTableName() matches the order in which mirroring historical tables are added with descriptor.addHistoryTableName().


addHistoryTableName

public void addHistoryTableName(java.lang.String sourceTableName,
                                java.lang.String historyTableName)
Use to specify the names of the mirroring historical tables.

Explicitly states that sourceTableName is mirrored by history table historyTableName. The order in which tables are added with descriptor.addTableName() should still match the order in which mirroring historical tables are added with descriptor.addMirroringHistoryTableName().


addStartFieldName

public void addStartFieldName(java.lang.String startFieldName)
Sets the name of the start field.

By default all tables belonging to a descriptor have the same primary key field names, and so the same start field names also.

However, if startFieldName is qualified, i.e. of the form "EMPLOYEE_HIST.EMP_START", then this call will only set the start field name for a single historical table.


setStartFieldType

public void setStartFieldType(java.lang.Class type)
ADVANCED: Sets the type of all start fields. Not required to be set as the default of Timestamp is assumed.


addEndFieldName

public void addEndFieldName(java.lang.String endFieldName)

See Also:
addStartFieldName(java.lang.String)

setEndFieldType

public void setEndFieldType(java.lang.String fieldName,
                            java.lang.Class type)
ADVANCED:

See Also:
setStartFieldType(java.lang.Class)

setShouldHandleWrites

public void setShouldHandleWrites(boolean value)
Sets if TopLink is responsible for writing history.

If history is maintained via low level database triggers or application logic a policy is still needed for point in time querying.

If Oracle flashback is used no HistoryPolicy is needed.

Setting this to false lets you use History for many other applications. For instance a table that tracks available flights or hotel deals may benefit from a HistoryPolicy just to simplify temporal querying.

If all hotel discounts have a start and end date, you could query on all discounts available at a certain date.


shouldHandleWrites

public boolean shouldHandleWrites()
Answers if TopLink is responsible for writing history.

If history is maintained via low level database triggers or application logic a policy is still usefull for point in time querying.

If Oracle flashback is used no HistoryPolicy is needed.

Returns:
true by default
See Also:
setShouldHandleWrites(boolean)

setShouldUseDatabaseTime

public void setShouldUseDatabaseTime(boolean value)
Sets if the Timestamp used in maintainaing history should be the current time according to the database.

Parameters:
value - if false uses localTime (default) instead

shouldUseLocalTime

public boolean shouldUseLocalTime()
Answers if the Timestamp used in maintaining history should be System.currentTimeMillis();

Returns:
true by default
See Also:
shouldUseDatabaseTime(), useLocalTime()

shouldUseDatabaseTime

public boolean shouldUseDatabaseTime()
Answers if the Timestamp used in maintaining history should be the current time according to the database.

Returns:
false by default
See Also:
shouldUseLocalTime(), useDatabaseTime()

useLocalTime

public void useLocalTime()
Answers if the Timestamp used in maintaining history should be System.currentTimeMillis();

See Also:
useDatabaseTime(), shouldUseLocalTime()

useDatabaseTime

public void useDatabaseTime()
Answers if the Timestamp used in maintaining history should be the current time according to the database.

See Also:
useLocalTime(), shouldUseDatabaseTime()

Copyright © 1998, 2012, Oracle. All Rights Reserved.