|
Claims  |
|
|
That which we claim is:
1. An object management system for an object oriented computing system
executing on a data processing system, said object oriented computing
system including a plurality of objects which are stored in nonvolatile
storage and which are processed in volatile storage, each object including
an object frame containing data attributes, and at least one object method
for performing actions on the associated object, said object management
system comprising:
a unit of work object class including a unit of work object frame
containing pointers to objects which are processed together by said object
oriented computing system, and including a first method for loading said
objects which are processed together from nonvolatile storage to volatile
storage, a second method for storing said objects which are processed
together from volatile storage to nonvolatile storage, and a third method
for generating in volatile storage a copy of said objects which are
processed together in volatile storage, said unit of work frame further
including pointers to said copy of said objects which are processed
together; and
means, responsive to a request to process selected ones of said plurality
of objects together, for generating an instance of said unit of work
object class, said instance of said unit of work object class including a
pointer to each selected object, such that said selected objects are
loaded from nonvolatile storage to volatile storage by invoking said first
method on said instance of said unit of work object class, and said
selected objects are stored in nonvolatile storage after processing by
invoking said second method on said instance of said unit of work object
class; and
means responsive to completion of a first step of said plurality of steps
on said selected objects, for generating a copy of said selected objects
in volatile storage, in modified condition from said first step, by
invoking said third method, such that said second step is performed on
said copy of said selected objects in nonvolatile storage.
2. The object management system of claim 1 wherein said unit of work object
frame includes a unit of work instance object table having pointers to
said objects which are processed together.
3. The object management system of claim 1 wherein said unit of work object
frame further includes a unit of work instance object table having
pointers to said objects which are processed together and to said copy of
said objects which are processed together.
4. An object oriented computing system, comprising:
data processing means;
nonvolatile storage means connected to said data processing means;
volatile storage means connected to said data processing means;
a plurality of objects which are stored in said nonvolatile storage means
and which are processed in said frame containing data attributes, and at
least one object method for performing actions on the associated object;
said plurality of objects including a unit of work object class having a
unit of work object frame containing pointers to objects which are
processed together by said object oriented computing system, and including
a first method for loading said objects which are processed together from
said nonvolatile storage means to said volatile storage means, and a
second method for storing said objects which are processed together from
said volatile storage means to said nonvolatile storage means; and
means, responsive to a request to process selected ones of said plurality
of objects together, for generating an instance of said unit of work
object class, said instance of said unit of work object class including a
pointer to each selected object, such that said selected objects are
loaded from said nonvolatile storage means to said volatile storage means
by invoking said first method on said instance of said unit of work object
class, and said selected objects are stored in said nonvolatile storage
means after processing by invoking said second method on said instance of
said unit of work object class;
wherein said objects which are processed together are processed in a
plurality of steps;
said unit of work object class further including a third method of
generating in said volatile storage means a copy of said objects which are
processed together in said volatile storage means, said unit of work
object frame further including pointers to said copy of said objects which
are processed together;
said object management system further comprising means responsive to
completion of a first step of said plurality of steps on said selected
objects, for generating a copy of said selected objects in said volatile
storage means, in modified condition from said first step, by invoking
said third method, such that said second step is performed on said copy of
said selected objects in said nonvolatile storage means.
5. The object oriented computing system of claim 4 wherein said unit of
work object frame includes a unit of work instance object table having
pointers to said objects which are processed together.
6. The object oriented computing system of claim 4 wherein said unit of
work object frame further includes a unit of work instance object table
having pointers to said objects which are processed together and to said
copy of said objects which are processed together.
7. An object management process for an object oriented computing system
executing on a data processing system, said object oriented computing
system including a plurality of objects which are stored in nonvolatile
storage and which are processed in volatile storage, each object including
an object frame containing data attributes, and at least one object method
for performing actions on the associated object, said object management
process comprising the steps of:
providing a unit of work object class including a unit of work object frame
containing pointers to objects which are processed together by said object
oriented computing system, and including a first method for loading said
objects which are processed together from nonvolatile storage to volatile
storage, and a second method for storing said objects which are processed
together from volatile storage to nonvolatile storage;
in response to a request to process selected ones of said plurality of
objects together, generating an instance of sad unit of work object class,
said instance of said unit of work object class including a pointer to
each selected object;
invoking said first method on said instance of said unit of work object
class to load said selected objects from nonvolatile storage to volatile
storage;
processing said selected objects in volatile storage; and
invoking said second method on said instance of said unit of work object
class to store said selected objects in nonvolatile storage after
processing;
wherein said objects which are processed together are processed in a
plurality of steps;
said unit of work object class including a third method for generating in
volatile storage a copy of said objects which are processed together in
volatile storage, said unit of work object frame further including
pointers to said copy of said objects which are processed together, and
wherein said processing step comprises the step of:
invoking said third method in response to completion of a first step of
said plurality of steps on said selected objects, to copy said selected
objects in volatile storage, in modified condition from said first step,
such that said second step is performed on said copy of said selected
objects in nonvolatile storage.
8. The object management process of claim 7 wherein said unit of work
object frame includes a unit of work instance object table having pointers
to said objects which are processed together.
9. The object management process of claim 7 wherein said unit of work
object frame further includes a unit of work instance object table having
pointers to said objects which are processed together and to said copy of
said objects which are processed together. |
|
|
|
|
Claims  |
|
|
Description  |
|
|
FIELD OF THE INVENTION
This invention relates to database management systems and more particularly
to a method and apparatus for preserving data integrity of the database.
BACKGROUND OF THE INVENTION
Computer based database management systems are widely used for storing and
manipulating large sets of related data. Database management systems may
be implemented on a personal computer, microcomputer or mainframe
computer, using a computer program called a database management program or
database manager. Although many database management systems are
implemented using conventional programming techniques, state-of-the-art
database management systems have been designed, and are now beginning to
appear commercially, using object oriented programming systems and
processes.
Object oriented programming systems and processes have been the subject of
much investigation and interest in state of the art data processing
environments. Object Oriented Programming is a computer program packaging
technique which provides reusable and easily expandable programs. In
contrast with known functional programming techniques which are not easily
adaptable to new functional requirements and new types of data, object
oriented programs are reusable and expandable as new requirements arise.
With the ever increasing complexity of computer based systems, object
oriented programming has received increased attention and investigation.
In an object oriented programming system, the primary focus is on data,
rather than functions. Object oriented programming systems are composed of
a large number of "objects". An object is a data structure and a set of
operations or functions that can access that data structure. The data
structure may be represented as a "frame". The frame has many "slots",
each of which contains an "attribute" of the data in the slot. The
attribute may be a primitive (i.e. an integer or string) or an Object
Reference which is a pointer to another object's instance or instances
(defined below). Each operation (function) that can access the data
structure is called a "method".
FIG. 1 illustrates a schematic representation of an object in which a frame
is encapsulated within its methods. FIG. 2 illustrates an example of an
object, in which the data structure relates to employee data and a number
of methods surround this data structure. One method, for example, obtains
the age of an employee. Each defined object will usually be manifested in
a number of "instances". Each instance contains the particular data
structure for a particular example of the object. For example, an object
for individual employee named Joyce Smith is an instance of the "employee"
object
Object oriented programming systems provide two primary characteristics
which allow flexible and reusable programs to be developed. These
characteristics are referred to as "encapsulation" and "inheritance". As
may be seen from FIG. 1, the frame is encapsulated by its methods
(functions). A wall of code has been placed around each piece of data. All
access to the frame is handled by the surrounding methods. Data
independence is thereby provided because an object's data structure is
accessed only by its methods. Only the associated methods know the
internal data structure. This ensures data integrity.
The "inheritance" property of object oriented programming systems allows
previously written programs to be broadened by creating new superclasses
and subclasses of objects. New objects are described by how they differ
from preexisting objects so that entirely new programs need not be written
to handle new types of data or functions.
FIG. 3 illustrates the inheritance property. For ease of illustration, the
objects are illustrated as rectangles rather than as circles, with the
object name at the top of a rectangle, the frame below the object name and
the methods below the frame. Referring to FIG. 3, three object classes are
illustrated for "salesperson", "employee" and "person", where a
salesperson is a "kind of" employee, which is a "kind of" person. In other
words, salesperson is a subclass of employee and employee is the
superclass of salesperson. Similarly, employee is the subclass of person
and person is the superclass of employee. Each class shown includes three
instances. B. Soutter, W. Tipp and B. G. Blue are salespersons. B.
Abraham, K. Yates and R. Moore are employees. J. McEnro, R. Nader and R.
Reagan are persons. In other words, an instance is related to its class by
an "is a" relation.
Each subclass "inherits" the frame and methods of its superclass. Thus, for
example, a salesperson frame inherits age and hire date objects as well as
promote methods from the employee superclass. Salesperson also includes a
unique quota attribute and a pay commission method. Each instance can
access all methods and frames of its superclass, so that, for example, B.
G. Blue can be promoted.
In an object oriented system, a high level routine requests an object to
perform one of its methods by sending the object a "message" telling the
object what to do. The receiving object responds to the message by
choosing the method that implements the message name, executing this
method and then returning control to the calling high level routine, along
with the results of the method.
Object oriented programming systems may be employed as database management
systems which are capable of operating upon a large database, and which
are expandable and adaptable. In an object oriented database management
system, the data in the database is organized and encapsulated in terms of
objects, with the instances of the objects being the data in the database.
Similarly, the database manager may be organized as a set of objects with
database management operations being performed by sending messages from
one object to another. The target object performs the requested action on
its attributes using its methods.
Whether a database management system is implemented using object oriented
programming or conventional programming, a major concern of a database
management system is preserving data integrity. Preserving data integrity
is difficult as the size and complexity of the data increases. Moreover,
for a very large database it is desirable to have multiple tasks performed
concurrently, thereby further impacting data integrity.
More specifically, a database manager typically controls the performance of
tasks on data in the database. Each task includes a number of steps, each
step of which may result in modification of data in the database. Data
integrity is lost when a task is aborted before completion. When a task is
aborted before completion, the preceding steps in the task may have
modified data in the database, thereby resulting in a loss of database
integrity. The task may be aborted because a step has failed or because,
under control of the database manager, a task is suspended in order to
perform a second task to provide "concurrent" task processing. In such a
concurrent scenario, the original task may never be completed, yet the
database may have been modified as a result of completed steps in the
original task. Moreover, each concurrently performed task may operate on
the same elements from the database, thereby causing a second task to
modify erroneous data placed in the database by the first task. Again,
data integrity is lost.
SUMMARY OF THE INVENTION
It is therefore an object of the invention to provide an improved database
management system.
It is another object of the invention to provide an improved database
management system which is implemented as an object oriented programming
system.
It is another object of the invention to provide an improved database
management system which preserves the integrity of data in a database.
It is another object of the invention to provide an improved database
management system which preserves the data integrity of the database
notwithstanding a task being aborted before completion.
It is yet another object of the invention to provide a database management
system which preserves the data integrity of the database during
performance of multiple concurrent tasks.
These and other objects are provided according to the invention, in a
database management system including a database of data elements stored in
a data storage device and a database manager operating on a data processor
for performing multiple tasks on the database, with each task including a
number of steps which are capable of modifying the data elements in the
database. According to the invention, the database manager includes a Unit
of Work manager. The Unit of Work manager assigns a Unit of Work instance
to each task and creates a Unit of Work level for each step in a task. In
an object oriented programming system, the Unit of Work is a new object
class, and an instance of the Unit of Work object class is created for
each object instance to be operated upon by a task.
According to the invention, each Unit of Work level for a task includes a
copy of the data elements from the database which are to be modified by
the task. Each step in the task is controlled to modify the data elements
in the associated Unit of Work level, rather than the data elements in the
database itself. Accordingly, if a task is interrupted before completion,
only the data elements in the Unit of Work level will have been modified.
The data elements in the database will not have been modified. Similarly,
if the database manager switches to a second task, the Unit of Work levels
may be saved, and may be recalled when the task resumes.
More particularly, according to the present invention, a Unit of Work level
is created for each step of a task. A succeeding Unit of Work level for a
succeeding step in a task includes a copy of the data elements to be
operated on by the succeeding step, in their "as modified" state from the
preceding Unit of Work level for the preceding step. These "nested" copies
provide a history trail of modifications made to the data. Accordingly,
while each step operates on data as it would appear from the preceding
step, the actual data in the database is not modified until the last step
in a task has successfully completed. Thus, it is possible to "roll back"
changes to the data at a particular Unit of Work level through appropriate
nesting of Unit of Work levels.
The Unit of Work manager of the present invention may be employed with
single task database management systems (i.e. systems which perform one
task at a time), to provide data integrity in case the task does not
complete or is suspended for any reason. Moreover, the Unit of Work
manager of the present invention may be employed with simultaneous task
database management systems (i.e. systems which can simultaneously perform
multiple tasks), to provide data integrity when tasks are switched before
completion. In that case, a copy of each Unit of Work instance is made for
each of the multiple tasks. Each of the multiple copies includes multiple
levels for each step as well.
The Unit of Work manager of the present invention may be implemented in
functionally programmed database management systems. However, the Unit of
Work manager is particularly advantageous for object oriented programming
systems because these systems typically operate upon very large databases
and are capable of multitasking. Object oriented programming systems
typically implement a "messy desk" environment, in which numerous
activities take place within the same application. In such an environment,
data integrity is difficult to maintain.
In an object oriented programming system, the Unit of Work of the present
invention is an object class, which includes methods for "commit",
"discard", "new", "notify", "rollback", "start" and "switch". The commit
method applies the changes made within the current Unit of Work level to
the preceding Unit of Work level. If commit is performed when the Unit of
Work level is "one", a physical update of the database occurs. Discard
removes the specified Unit of Work instance from the system. All data
within the discarded Unit of Work instance is lost. New begins an entirely
new Unit of Work instance. Notify is used by an application program to
tell the Unit of Work manager that a data element is about to be modified.
Rollback destroys the changes made within the current Unit of Work level
and drops back to the preceding Unit of Work level. Start begins a new
nested Unit of Work level within the current Unit of Work instance.
Finally, Switch is used to leave the current Unit of Work instance and to
enter another, previously defined Unit of Work instance.
BRIEF DESCRIPTION OF THE DRAWINGS
FIG. 1 illustrates a schematic representation of an object.
FIG. 2 illustrates a schematic representation of the example of an object.
FIG. 3 illustrates the inheritance property of objects.
FIG. 4 illustrates a schematic block diagram of an object oriented computer
system according to the present invention .
FIG. 5 illustrates a schematic block diagram of an object oriented program
according to the present invention.
FIG. 6 illustrates a schematic representation of a Unit of Work instance of
the present invention, including multiple objects and multiple Unit of
Work levels.
FIG. 7 illustrates a schematic representation of the object table for a
Unit of Work Instance according to the present invention.
FIG. 8 illustrates multiple Unit of Work instances, according to the
present invention.
FIG. 9 illustrates multiple Unit of Work instances after the start of a new
level according to the present invention.
FIGS. 10 through 12 illustrate Units of Work of the present invention
before and after implementation of Switch and Discard methods.
FIG. 13 illustrates a schematic diagram of the operations implemented in a
first example of the present invention.
FIGS. 14 through 16 illustrate objects in memory and in a database during
buildup of the Unit of Work levels of the present invention.
FIGS. 17 and 18 illustrate objects in memory and in a database during a
first example of the present invention.
FIG. 19 illustrates a schematic diagram of the operations implemented in a
second example of the present invention.
FIGS. 20 and 21 illustrate objects in memory and in a database during a
second example of the present invention.
FIG. 22 illustrates a schematic diagram of the operations implemented in a
third example of the present invention.
FIGS. 23 and 24 illustrate objects in memory and in a database during a
third example of the present invention.
FIG. 25 illustrates a schematic diagram of the operations implemented in a
fourth example of the present invention.
FIGS. 26 and 27 illustrate objects in memory and in a database during a
fourth example of the present invention.
DESCRIPTION OF THE PREFERRED EMBODIMENT
The present invention now will be described more fully hereinafter with
reference to the accompanying drawings, in which a preferred embodiment of
the invention is shown. This invention may, however, be embodied in many
different forms and should not be construed as limited to the embodiment
set forth herein; rather, this embodiment is provided so that this
disclosure will be thorough and complete, and will fully convey the scope
of the invention to those skilled in the art. Like numbers refer to like
elements throughout.
OBJECT ORIENTED COMPUTER SYSTEM
In an object oriented computer system, work is accomplished by sending
action request messages to an object which contains (encapsulates) data.
The object will perform the requested action on the data according to its
predefined methods. The requestor of the action need not know what the
actual data looks like or how the object manipulates it.
An object's class defines the types and meanings of the data and the action
requests (messages) that the object will honor. The individual objects
containing data are called instances of the class. Classes generally
relate to real-world things. For example, "Parts" may be a class. The data
elements (slots) of a part might be a part number, a status and a part
type. The instances of this class represent individual parts, each with
its own part number, status, and type information. The programs performing
the requested actions are called methods of the class.
Object classes can be defined to be subclasses of other classes. Subclasses
inherit all the data characteristics and methods of the parent class. They
can add additional data and methods, and they can override (redefine) any
data elements or methods of the parent class. While most messages are sent
to object instances, the message that requests that a new instance be
created is sent to an object class. The class will cause a new instance to
be created and will return an object identifier by which that object will
be known.
The sender of an action request message need not know the exact class of
the object to which it is sending the message. As long as the target
object either defines a method to handle the message or has a parent class
that defines such a method, then the message will be handled using the
data in the object instance and the method in its class or its parent
class. In fact, it need not be an immediate parent, but may be a parent's
parent, etc. The sender of the method need only have the object ID of the
receiving object. This property of object oriented systems is called
"inheritance". The inheritance property is used in the present invention.
Referring now to FIG. 4, a schematic block diagram of an object oriented
computer system 10 is illustrated. The system 10 includes a data processor
11 which may be a mainframe computer, minicomputer or personal computer.
For large databases having multiple users, a mainframe computer is
typically employed. As is well known to those having skill in the art, the
data processor 10 includes a volatile data storage device 13, typically
random access memory (RAM) for providing a working store for active data
and intermediate results. Data in RAM 13 is erased when power to the data
processor 11 is removed or a new user session is begun. System 10 also
includes a nonvolatile data storage device 14 for permanent storage of
objects. Device 14 may be a direct access storage device (DASD-a disk
file) a tape file, an erasable optical disk or other well known device.
Nonvolatile data storage device 14 will also be referred to herein as a
"database". Volatile data storage device 13 will also be referred to as
"memory". A display terminal 15 including a cathode ray tube (CRT) or
other display, and a keyboard, is also shown.
An object oriented operating program 12 is also included in data processor
11. Object oriented operating program 12 may be programmed in object
oriented languages such as "C" or "Smalltalk" or variations thereof, or in
conventional programming languages such as FORTRAN or COBOL. The design of
an object oriented operating program 12 is well known to those skilled in
the art of object oriented programming systems, and will only be described
generally below.
Referring now to FIG. 5, the main components of an object oriented program
(12, FIG. 4) will be described. A more detailed description of the design
and operation of an object oriented program is provided in "Object
Oriented Software Construction", by Bertrand Meyer, published by Prentice
Hall in 1988, the disclosure of which is incorporated herein by reference.
Referring to FIG. 5, object oriented program 12 includes three primary
components: a Messenger 51, an Object Management Table 52 and a Loaded
Classes Table 53. The Messenger 51 controls communication between calling
and called messages, Object Management Table 52 and Loaded Classes Table
53. Object Management Table 52 contains a list of pointers to all active
object instances. The Loaded Classes Table 53 contains a list of pointers
to all methods of active object classes.
Operation of the Object Oriented Program 12 will now be described for the
example illustrated in FIG. 5, in which Method A (block 54) of an object
sends a message to Method B (block 55) of an object. Method A sends a
message to Method B by calling Messenger 51. The message contains (1) an
object reference of the instance to receive the message, (2) the method
the object instance is requested to perform on the data it encapsulates,
and (3) any parameters needed by the receiving method. Messenger 51
obtains a pointer to the data frame 56 of the instance object specified by
Method A, by searching Object Management Table 52 for the instance object.
If the specified instance object cannot be found, Object Management Table
52 adds the instance object to the table and calls the instance to
materialize its data from the database. Once in the instance table, Object
Management Table 52 returns the pointer to the materialized instance
object.
Messenger 51 then obtains the address of Method B from the Loaded Classes
Table 53. If the instance's class is not loaded, the Loaded Classes Table
53 will load it at this time to materialize its data. The Loaded Classes
Table 53 searches for the specified method (Method B) and returns the
address of the method to Messenger 51.
The Messenger 51 then calls Method B, passing it a system data area and the
parameters from the call made by Method A including the pointer. Method B
accesses the data frame 56 using the pointer. Method B then returns
control to the Messenger 51 which returns control to Method A.
Object oriented program 12 typically includes a table for the methods
associated with each object. This method table contains the method number
and the corresponding address where the method is located. In addition,
object oriented program 12 also typically includes an object
identification table for each object. This table contains all instances
for the object and the corresponding address or OREF for each instance.
These tables are used in processing for executing the methods and for
accessing objects as well as data instances of objects.
In many programming activities, and in object oriented programming systems
in particular, it is desirable to process a number of tasks independently
and in parallel without having one task impact another. Many database
systems restrict a program to a single, sequentially ordered task. The
primary restriction is the inability to specify what gets committed,
rolled back, locked, or released. Additionally, resources are generally
released after every database commit. These restrictions make it difficult
to allow a user to operate within a "messy desk" environment where there
are numerous concurrent activities within the same application.
The "Unit of Work" object class of the present invention allows one or more
actions to be performed within a control context. In an object oriented
programming system having the Unit of Work object class of the present
invention, an application program identifies Units of Work. The object
oriented program 12 (FIG. 4) includes a Unit of Work Manager, which
provides application programs the ability to manage data and maintain the
relational integrity of related work activities.
In operation, Unit of Work Manager is initiated by an application program.
Programs which modify data are responsible for notifying the Unit of Work
Manager. The Unit of Work manager makes multiple copies of the same object
instance as a processing task proceeds through Unit of Work levels.
Essentially, these multiple instances give a history trail of
modifications made to the data. Thus, it is possible to "roll back"
changes to the data at a particular Unit of Work level through appropriate
nesting of Unit of Work levels. The Unit of Work Manager is used by a task
to control a logical Unit of Work instance. The Unit of Work Manager is
accessed by the task which then sends requests to the Unit of Work Manager
as required to manipulate the current Unit of Work instance.
Referring now to FIG. 6, there are two major uses for the Unit of Work
object class of the present invention. The first use is for multiple,
concurrent Unit of Work levels for each object. An object table, known as
a Unit.sub.-- Of.sub.-- Work.sub.-- Instance.sub.-- Object.sub.-- Table,
as represented in FIG. 7, exists for each Unit of Work instance. An
example of a Unit of Work instance for an object is if Object.sub.-- A in
FIG. 6 were equivalent to Salesperson object in FIG. 3, then the multiple
object instances of Salesperson object, i.e. Object.sub.-- A, would be B.
Soutter, W. Tipp, and B. G. Blue. Multiple Unit of Work instances are
illustrated in FIG. 8 where Object.sub.-- A, Object.sub.-- B and
Object.sub.-- C in FIG. 6 can be represented collectively, as a single
Unit of Work instance and Unit of Work Instance.sub.-- I, Unit of Work
Instance.sub.-- II and Unit of Work Instance.sub.-- III illustrate three
Unit of Work instances in FIG. 8. The second use is for creating Unit of
Work levels within a particular Unit of Work instance, respectively
referred to in FIG. 6 as UOW Level 1, UOW Level 2 and UOW Level 3.
Multiple Unit of Work instances simply means that two or more Units of Work
referred to as Unit of Work Instance.sub.-- I, Unit of Work
Instance.sub.-- II, and Unit of Work Instance.sub.-- III in FIG. 8 may
exist simultaneously and yet operate independently from each other. This
is also true for Objects themselves, such as Object.sub.13 A,
Object.sub.-- B and Object.sub.-- C in FIG. 6. This concept allows
database commits to occur which only affect one particular Unit of Work
instance for Object.sub.-- A such as Unit of Work Instance.sub.-- I in
FIG. 8. Additionally, multiple Unit of Work instances allow a user to
"switch" from Unit of Work instance to Unit of Work instance as desired,
i.e. Unit of Work Instance.sub.-- I to Unit of Work Instance.sub.-- II.
Unit of Work levels 1, 2, and 3 control those Unit of Work related
activities within a particular Unit of Work instance. Only actions which
commit the lowest level of a particular Unit of Work instance, i.e. level
1, will actually impact the database.
UNIT OF WORK OBJECT CLASS--ATTRIBUTES
The major attributes of the Unit of Work object class of the present
invention include:
Unit.sub.-- of-Work.sub.-- Instance.sub.--ID
Unit.sub.-- of.sub.-- Work.sub.-- Instance.sub.-- ID uniquely identifies a
Unit of Work instance.
Unit.sub.-- of.sub.-- Work.sub.-- Instance.sub.-- Current.sub.-- Level
Unit.sub.-- of.sub.-- Work.sub.-- Instance.sub.-- Current.sub.-- Level
indicates the Unit of Work level for a given Unit of Work instance.
Unit.sub.-- of.sub.-- Work.sub.-- Previous.sub.-- Instance.sub.-- ID
Unit.sub.-- of.sub.-- Work.sub.-- Previous.sub.-- Instance.sub.-- ID
uniquely identifies which instance had control prior to control being
transferred to a newly created Unit of Work instance or a switch.
Unit.sub.-- of.sub.-- Work.sub.-- Instance.sub.-- Object.sub.-- Table
(Unit.sub.-- of.sub.-- Work.sub.-- Instance.sub.-- Object.sub.-- List)
The Unit.sub.-- of.sub.-- Work.sub.-- Instance.sub.-- Object.sub.-- Table
is maintained for each Unit of Work instance. The two dimensional table
contains the objects for the Unit of Work instance and the Unit of Work
levels at which the object is found within the Unit of Work instance. One
implementation provides columns labelled by object and rows labelled by
Unit of Work levels. An address to the instance of an object or an OREF is
maintained at the intersection of the particular object column and Unit of
Work level row in the table. Where no address or OREF is found, the object
is not present at that particular Unit of Work level in the particular
Unit of Work instance.
For example, referring to FIG. 7, a Unit.sub.-- of.sub.-- Work.sub.--
Instance.sub.-- Object.sub.-- Table is shown for the Unit of Work instance
in FIG. 6. Since there is no instance of Object.sub.-- B at Unit of Work
level 2 or Object.sub.-- C at Unit of Work level 3 in the Unit of Work
instance illustrated in FIG. 6, there is correspondingly no entry in the
Unit.sub.-- of.sub.-- Work.sub.-- Instance.sub.-- Object.sub.-- Table for
those objects at those Unit of Work levels.
UNIT OF WORK OBJECT CLASS--METHODS
The Unit of Work object class of the present invention provides seven
methods which act on objects in the object oriented environment. These
methods include New, Start, Notify, Discard, Switch, Commit and Rollback.
Each method manipulates one of the above counters as well as other
attributes.
New
The New method begins an entirely new Unit of Work instance and returns a
handle to the calling application program. The handle uniquely identifies
the new Unit of Work instance. All data referenced within this Unit of
Work instance are newly created or selected, even if the data has already
been previously selected within another Unit of Work instance.
Additionally, when this Unit of Work instance is discarded, all memory
associated with any data which have been either selected or created within
this Unit of Work instance is also freed.
Start
The Start method tells the Unit of Work instance to begin a new, nested
Unit of Work level within the current Unit of Work instance.
Notify
The Notify method permits the application program to tell the Unit of Work
Manager that a data element is about to be modified and causes the data
element to be "copied into" the current Unit of Work level in the current
Unit of Work instance.
Discard
The Discard method removes the specified Unit of Work instance from memory
resulting in the loss of data within the Unit of Work instance and no
effect on the database.
Switch
The Switch method causes control to leave the current Unit of Work instance
and to enter another previously defined Unit of Work instance using the
control (handle or unique identifier) returned by the New feature.
Commit
The commit method applies the changes made within the current Unit of Work
level indicated by Unit.sub.-- of.sub.-- Work.sub.-- Instance.sub.--
Current.sub.-- Level to the preceding Unit of Work level. A commit
performed when the Unit of Work level is one, results in a physical update
and a commit of the database. The Unit of Work instance which commits
successfully will ensure that the update of each data element was
successful.
Rollback
The Rollback method destroys changes made within the current Unit of Work
level indicated by Unit.sub.-- of.sub.-- Work.sub.-- Instance.sub.--
Current.sub.-- Level and returns control to the previous Unit of Work
level. If a database operation was unsuccessful, the Unit of Work level is
considered to be "un-committable". The database will be rolled back, all
data objects will be left in their updated states at Unit of Work level 1
in memory and not copied to the database. The Unit of Work Manager will
return control to the calling application program which issued the commit
with an error indicating which data element failed the database update and
the reason for the failure.
More specifically, referring to FIG. 8, the method New will create a new
Unit of Work instance, i.e. Unit of Work Instance.sub.-- III, for the
object specified by the applications program. New has three attributes
including a Unit.sub.-- of.sub.-- Work.sub.-- Instance.sub.--
Current.sub.-- Level for this Unit of Work instance, a previous Unit of
Work instance indicator, Unit.sub.-- of.sub.-- Work.sub.-- Previous.sub.--
Instance.sub.-- ID, that indicates which Unit of Work instance had control
prior to the new creation, and a list of objects that this newly created
Unit of Work instance knows about which can be represented as a table,
Unit.sub.-- of.sub.-- Work.sub.-- Instance.sub.-- Object.sub.-- Table
(FIG. 7). Note that the list will contain at level one, copies of the
objects as they appear in the database and the Unit.sub.-- of.sub.--
Work.sub.-- Instance.sub.-- Current.sub.-- Level will be set to one since
the Unit of Work instance was just created. The operation of New will be
further described in the examples for the Commit and Rollback methods.
The method Start creates a new level of work in the currently active Unit
of Work instance. There is a Unit.sub.-- of.sub.-- Work.sub.--
Instance.sub.-- Current.sub.-- Level for each instance that tells which
Unit of Work level within an Unit of Work instance is currently active.
This current level indicator in the active instance is incremented. Thus,
if Unit of Work Instance.sub.-- II is the currently active Unit of Work
instance, Start.sub.-- II will cause the Unit of Work manager to create a
new Unit of Work level, namely level 2, for Unit of Work Instance.sub.--
II since its current level is 1. The Unit.sub.-- of.sub.-- Work.sub.-- | | |