Schema mapping to a legacy table with primary and foreign key support
First Claim
1. A computer-implemented method for mapping an object having an object class and an independent handle having a handle class between object-oriented schema and relational database schema, said object class defining fields represented by instance variables, said handle class defining fields represented by instance variables, said relational database schema defined by a table having a plurality of columns for storing a persistent state of said object, the method comprising the steps of:
- determining whether a group of one or more of said columns is pre-defined as a primary key;
selecting a group of one or more fields represented by instance variables of said handle class defining a unique identity for said object;
generating mapping software code in a high-level language, said mapping software code defining a mapping between said group of columns pre-defined as a primary key and said instance variables representing said fields of said handle class defining a unique identity for said object;
retrieving, in response to an instantiation request at application program runtime, a group of one or more values from said group of one or more columns defined as a primary key; and
instantiating a handle object of said handle class in response to said request, said handle object having said instance variables representing said group of one or more fields of said handle class defining a unique identity for said object set to said values in accordance with said mapping.
1 Assignment
0 Petitions
Accused Products
Abstract
A method and system for mapping an object and an associated handle between the object-oriented schema of an application program and the relational schema of a database in which the object is persisted. The handle is reconstructed in response to a run-time request by an application program to instantiate the object. The handle may be an independent handle or an embedded handle. The relationships afforded by primary keys and foreign keys in a legacy, i.e., existing, relational database, can be preserved by mapping them to the independent and embedded handles, respectively. The mapping is performed prior to application program run-time, and is defined in a high-level schema mapping language, which may be generated with the aid of a schema mapping software tool.
-
Citations
15 Claims
-
1. A computer-implemented method for mapping an object having an object class and an independent handle having a handle class between object-oriented schema and relational database schema, said object class defining fields represented by instance variables, said handle class defining fields represented by instance variables, said relational database schema defined by a table having a plurality of columns for storing a persistent state of said object, the method comprising the steps of:
-
determining whether a group of one or more of said columns is pre-defined as a primary key; selecting a group of one or more fields represented by instance variables of said handle class defining a unique identity for said object; generating mapping software code in a high-level language, said mapping software code defining a mapping between said group of columns pre-defined as a primary key and said instance variables representing said fields of said handle class defining a unique identity for said object; retrieving, in response to an instantiation request at application program runtime, a group of one or more values from said group of one or more columns defined as a primary key; and instantiating a handle object of said handle class in response to said request, said handle object having said instance variables representing said group of one or more fields of said handle class defining a unique identity for said object set to said values in accordance with said mapping. - View Dependent Claims (2, 3, 4, 5, 6)
-
-
7. A computer-implemented method for mapping an object having an object class and referenced by an embedded handle between object-oriented schema and relational database schema, said embedded handle having a handle class, said object class defining fields represented by instance variables, said handle class defining fields represented by instance variables, said relational database schema defined by a table having a plurality of columns, the method comprising the steps of:
-
determining whether a group of one or more of said columns is pre-defined as a foreign key; selecting a group of one or more fields represented by instance variables of said handle class defining a unique identity for said object; generating mapping software code in a high-level language, said mapping software code defining a mapping between said group of columns pre-defined as a foreign key and said instance variables representing said fields of said handle class defining a unique identity for said object; retrieving, in response to an instantiation request at application program runtime, a group of one or more values from said group of one or more columns defined as a primary key; and instantiating an embedded handle object of said handle class in response to said request, said embedded handle object having said instance variables representing said group of one or more fields of said handle class defining a unique identity for said object set to said values in accordance with said mapping. - View Dependent Claims (8, 9, 10, 11)
-
-
12. A system for mapping an object having an object class and an assocated handle having a handle class between object-oriented schema and relational database schema, said object class defining fields represented by instance variables, said handle class defining fields represented by instance variables, said relational database schema defined by a table having a plurality of columns for storing a persistent state of said object, the method comprising the steps of:
- , the system comprising;
a schema mapping tool for receiving from a user a selection of a group of one or more instance variables defining a unique identity for said object, for receiving from said user a mapping between said instance variables and a key of said relational database schema, and for generating mapping software code in a high-level language in response to said selection and said mapping; and a schema map run-time code generator for instantiating a schema map object and a key object at application program run-time, said schema map object instantiating a handle object in response to a request for restoring an object from a database, said handle object having an object identifier field represented by a group of one or more of said instance variables set to values retrieved from said database in accordance with said mapping. - View Dependent Claims (13, 14)
- , the system comprising;
-
15. A computer program product for mapping an object having an object class and an assocated handle having a handle class between object-oriented schema and relational database schema, said object class defining fields represented by instance variables, said handle class defining fields represented by instance variables, said relational database schema defined by a table having a plurality of columns for storing a persistent state of said object, said computer program product comprising a signal-bearing medium carrying thereon:
-
a schema mapping tool for receiving from a user a selection of a group of one or more instance variables defining a unique identity for said object, for receiving from said user a mapping between said instance variables and a key of said relational database schema, and for generating mapping software code in a high-level language in response to said selection and said mapping; and a schema map run-time code generator for instantiating a schema map object and a key object at application program run-time, said schema map object instantiating a handle object in response to a request for restoring an object from a database, said handle object having an object identifier field represented by a group of one or more of said instance variables set to values retrieved from said database retrieved in accordance with said mapping.
-
Specification