Abstract:
An object persistence mechanism is disclosed that enables the generation of software objects that have persistent data and a mutable key. A mutable key capability is advantageous in a variety of applications, such as monitoring a set of users and their login status on a plurality of media servers (e.g., an email server, an instant messaging server, a voice mail server, a video server, an audio-conferencing server, etc.). Implementations based on the Enterprise JavaBean specification are disclosed for three illustrative embodiments of the present invention. The illustrative embodiments of the present invention can also be implemented in accordance with object persistence mechanisms other than Enterprise JavaBeans.

Description:
FIELD OF THE INVENTION  
       [0001]     The present invention relates to software in general, and, more particularly, to the generation of persistent objects that have mutable keys.  
       BACKGROUND OF THE INVENTION  
       [0002]     Object persistence is a mechanism by which an object instance that resides in volatile memory (e.g., random-access memory [RAM], etc.) is mapped to a database, thereby providing permanent storage of the object instance&#39;s data. For example, if a source program creates and instantiates a persistent employee object instance, the data associated with the object instance is automatically stored in a database, without any explicit programming. As a result, if a hardware failure were to occur during the execution of a program that processes employee records, the most recent data for the employees would automatically be retained. Object persistence thus provides a mechanism for the permanent storage of data.  
         [0003]     Object persistence also provides a mechanism for mapping an object instance&#39;s fields to a database, thereby enabling a programmer to (i) retrieve object information from a database without writing explicit database-handling code, and (ii) manipulate objects without having to constantly save changes back to the database. When persistent objects are mapped to a relational database, the mapping mechanism is referred to as object-relational mapping.  
         [0004]      FIG. 1  depicts an illustrative object-relational mapping between object class  100  and database schema  110 , in accordance with the prior art.  
         [0005]     Object class  100  is a class named User that comprises six fields: ssn, lastName, firstName, birthdate, zipCode, and gender. As indicated by the underlined bold typeface, field ssn, which corresponds to social security number, is the key for object class  100  (i.e., each instance of User is uniquely identified by its ssn value).  
         [0006]     Database schema  110  is a relation that comprises six attributes: Last, First, SSN (the schema key), Zip, Sex, and DOB.  
         [0007]     The dotted arrows in  FIG. 1  indicate the object-relational mapping between fields of object class  100  and attributes of database schema  110 . As will be appreciated by those skilled in the art, a complete specification of object class  100  and database schema  110  would include data type information for the fields and attributes.  
         [0008]      FIG. 2  depicts illustrative object instances  200 - 1  and  200 - 2 , and illustrative database table  210  in accordance with the prior art.  
         [0009]     Object instances  200 - 1  and  200 - 2 , named user 1  and user 2 , respectively, are instances of object class  100 .  
         [0010]     Database table  210  is a table in accordance with database schema  110 . As shown in  FIG. 2 , database table  210  comprises rows  220 - 1  through  220 -N, where N is a positive integer.  
         [0011]     The arrows in  FIG. 2  indicate illustrative object-relational mappings between database table  210  and object instances  200 - 1  and  200 - 2 . In particular, object instance  200 - 1  is mapped to table row  220 - 2 , and object instance  200 - 2  is mapped to table row  220 -N, in accordance with the object-relational mapping of  FIG. 1 . The mapping between an object instance and a table row indicates that either: 
        (i) the object instance was created (e.g., by a constructor, factory method, etc.) and its field values were then automatically persisted in the table row; or     (ii) the object instance was instantiated with the pre-existing attribute values of the table row. 
 
 In case (ii), the object instance is instantiated by invoking a finder method that: 
    (a) takes the value of a key (in this case, a social security number) as an argument, and     (b) instantiates the fields of the object instance with the attribute values of the table row.        
 
         [0016]     Enterprise JavaBeans is a specification from Sun Microsystems® for both object persistence and transaction processing. In particular, the Enterprise JavaBean (EJB) specification defines entity beans, which are persistent objects that are mapped to a relational database, and session beans, which are used to process transactions and are not persistent.  
         [0017]     Entity Beans have at least one primary key that uniquely identifies each bean instance. The primary key can consist of a single field (e.g., social security number, etc.), or a plurality of fields. As an example of the latter, an entity bean for storing sales records might use the social security number of the sales agent in combination with the date/time of the sale as the primary key.  
         [0018]     In accordance with the Enterprise JavaBean (EJB) specification, primary keys are immutable—i.e., their value must be specified when an entity bean instance is created, and their value cannot change during the life of the entity bean instance. Entity bean fields that do not belong to a primary key, in contrast, are mutable—i.e., their value can change during the life of the entity bean instance, and they do not have to be initialized when the entity bean instance is created.  
       SUMMARY OF THE INVENTION  
       [0019]     In some situations it would be advantageous to have an entity Enterprise JavaBean (or another kind of persistent object) with a primary key that is mutable. For example, consider an application that monitors a set of users and their login status on various media servers such as email, instant messaging, voice mail, video, and audio-conferencing servers. The email server identifies a particular user U by his or her email address; the audio-conferencing server identifies user U by his or her telephone number; and so on.  
         [0020]     In such an application, it would be natural to have a User entity bean that has a first primary key field for the user&#39;s email address, a second primary key field for the user&#39;s telephone number, etc., and to have the media servers report the login status of users to the User entity beans. The problem, however, is that the set of identifying information for a user can change over time, and typically only a subset of this information is known initially. For example, a user might first log in to an email server, ten minutes later log in to an audio-conferencing server, five minutes later log out of the email server, and so on. However, because entity JavaBean primary keys are immutable, the user&#39;s log-in information for all possible media servers would have to be specified as soon as the user logged into any one of the media servers. Furthermore, the User entity bean could not reflect changes in the user&#39;s log-in status over time.  
         [0021]     The present invention addresses this problem via a mechanism that enables the generation of objects that have persistent data and a mutable key. Implementations are disclosed for three illustrative embodiments based on the Enterprise JavaBean specification. The illustrative embodiments can also be implemented in accordance with object persistence mechanisms other than Enterprise JavaBeans.  
         [0022]     The illustrative embodiment comprises: generating a first object class that comprises one or more persistent fields and a method for accessing a mutable key. 
     
    
     BRIEF DESCRIPTION OF THE DRAWINGS  
       [0023]      FIG. 1  depicts an illustrative object-relational mapping, in accordance with the prior art.  
         [0024]      FIG. 2  depicts two illustrative object instances of object class  100 , as shown in  FIG. 1 , and an illustrative database table corresponding to database schema  110 , as shown in  FIG. 1 , in accordance with the prior art.  
         [0025]      FIG. 3  depicts three illustrative object classes, in accordance with the first illustrative embodiment of the present invention.  
         [0026]      FIG. 4  depicts illustrative object-relational mappings for classes  301  and  302 , as shown in  FIG. 3 , in accordance with the first illustrative embodiment of the present invention.  
         [0027]      FIG. 5  depicts object instances of class  300 ,  301 , and  302  after the execution of illustrative source code  503 , in accordance with the first illustrative embodiment of the present invention.  
         [0028]      FIG. 6  depicts object instances  500 ,  501 - 1 , and  502 , as shown in  FIG. 5 , after the execution of illustrative source code  603 , in accordance with the first illustrative embodiment of the present invention.  
         [0029]      FIG. 7  depicts object instances  500 ,  501 - 1 ,  501 - 2 , and  502  after the execution of illustrative source code  703 , in accordance with the first illustrative embodiment of the present invention.  
         [0030]      FIG. 8  depicts object instances  500 ,  501 - 1 ,  501 - 2 ,  501 - 3 , and  502  after the execution of illustrative source code  803 , in accordance with the first illustrative embodiment of the present invention.  
         [0031]      FIG. 9  depicts three illustrative object classes, in accordance with the second illustrative embodiment of the present invention.  
         [0032]      FIG. 10  depicts object instances of class  300 ,  901 , and  302  after the execution of illustrative source code  1003 , in accordance with the second illustrative embodiment of the present invention.  
         [0033]      FIG. 11  depicts object instances  1000  and  1002 , as shown in  FIG. 10 , and new object instance  1001 - 2  after the execution of illustrative source code  1103 , in accordance with the second illustrative embodiment of the present invention.  
         [0034]      FIG. 12  depicts object instances  1000  and  1002  and new object instance  1001 - 3  after the execution of illustrative source code  1203 , in accordance with the second illustrative embodiment of the present invention.  
         [0035]      FIG. 13  depicts three illustrative object classes, in accordance with the third illustrative embodiment of the present invention.  
         [0036]      FIG. 14  depicts object instances of class  1300 ,  901 , and  302  after the execution of illustrative source code  1403 , in accordance with the third illustrative embodiment of the present invention.  
         [0037]      FIG. 15  depicts object instances  1400  and  1402 , as shown in  FIG. 14 , and new object instance  1401 - 2  after the execution of illustrative source code  1503 , in accordance with the third illustrative embodiment of the present invention.  
         [0038]      FIG. 16  depicts object instances  1400  and  1402  and new object instance  1401 - 3  after the execution of illustrative source code  1603 , in accordance with the third illustrative embodiment of the present invention.  
         [0039]      FIG. 17  depicts object instances  1400  and  1402  and new object instance  1401 - 4  after the execution of illustrative source code  1703 , in accordance with the third illustrative embodiment of the present invention.  
         [0040]      FIG. 18  depicts object instances  1400  and  1402  and new object instance  1401 - 5  after the exe/*cution of illustrative source code  1803 , in accordance with the third illustrative embodiment of the present invention.  
         [0041]      FIG. 19  depicts object instances  1400  and  1402  and new object instance  1401 - 6  after the execution of illustrative source code  1903 , in accordance with the third illustrative embodiment of the present invention. 
     
    
     DETAILED DESCRIPTION  
       [0042]     The terms appearing below are given the following definitions for use in this Description and the appended claims.  
         [0043]     For the purposes of the specification and claims, the term “persistent object instance” is an object instance that is mapped to a record in a persistent store. The mapping might be managed by one or more methods of the object instance, or might be managed automatically by a separate persistence mechanism. An Enterprise JavaBeans entity bean instance is an example of a persistent object instance.  
         [0044]     For the purposes of the specification and claims, the term “persistent field” is an object field whose value is mirrored in a persistent store (e.g., a database, etc.) without explicit programming by the developer who created the object or the class to which the object belongs. A persistent field might belong to a non-persistent object instance, such as a field of a regular Java class, as well as to a persistent object instance.  
         [0045]     For the purposes of the specification and claims, the term “key” is a datum, or a collection of data, that uniquely identifies an entity. Examples of keys include an Enterprise JavaBean primary key, a key of a table in a relational database, and so forth.  
         [0046]     The illustrative embodiments of the present invention, described below and with respect to  FIGS. 3 through 19 , are disclosed in the context of Enterprise JavaBeans; however, it will be clear to those skilled in the art how to make and use alternative embodiments that are based on other object persistence mechanisms.  
         [0047]      FIG. 3  depicts three illustrative object classes, in accordance with the first illustrative embodiment of the present invention.  
         [0048]     Object class  300  is named User and comprises eight fields: ssn (the key), lastName, firstName, birthdate, zipCode, gender, emailAddr, and phoneNum. In accordance with the first illustrative embodiment, object class  300  is a regular Java class. However, it will be clear to those skilled in the art how to make and use alternative embodiments in which class  300  is a session Enterprise JavaBean, or an inner class of a Java servlet, or some other kind of class.  
         [0049]     Object class  301  is an entity bean class (i.e., a class that implements interface javax.ejb.EntityBean and has persistent instances) named UserAliasBean that comprises two fields: immutable key alias, and foreignKey.  
         [0050]     Object class  302  is an entity bean class named UserTargetBean that comprises six fields: immutable key internalKey, whose values are automatically generated by the relational database management system; lastName; firstName; birthdate; zipCode; and gender.  
         [0051]     As depicted by the arrows in  FIG. 3 , object classes  300 ,  301 , and  302 , are related as follows: ssn, emailAddr, and phoneNum of User  300  relate to alias of UserAliasBean  301 ; and foreignKey of UserAliasBean  301  relates to UserTargetBean  302 .  
         [0052]      FIG. 4  depicts illustrative object-relational mappings for classes  301  and  302 , in accordance with the first illustrative embodiment of the present invention. As depicted by the dotted arrows, the fields of class  301  are mapped to attributes of two relational database schemas: schema  410  and schema  420 .  
         [0053]      FIG. 5  depicts object instances of class  300 ,  301 , and  302  and illustrative source code  503  and  504 , in accordance with the first illustrative embodiment of the present invention. Object instances  500 ,  501 - 1 , and  502  are instances of class  300 ,  301 , and  302 , respectively, that are created as a result of the execution of illustrative source code  503 . As shown in  FIG. 5 , illustrative source code  503  creates object instance  500  via a conventional Java constructor. It will be appreciated by those skilled in the art that in some other embodiments of the present invention, source code  503  might instead create object instance  500  via a factory pattern (e.g., when object instance  500  is a session Enterprise JavaBean, etc.).  
         [0054]      FIG. 5  also depicts illustrative source code  504 , which comprises an illustrative implementation of the User( ) constructor. This implementation: 
        takes a String argument that corresponds to social security number and copies the argument into object instance  500 &#39;s field ssn;     creates UserAlias bean  501 - 1 , whose alias is the social security number;     creates UserTarget bean  502 ; and     sets the value of the foreign key of UserAlias bean  501 - 1  to the internal key of UserTarget bean  502 .          
         [0059]      FIG. 6  depicts object instances  500 ,  501 - 1 , and  502  after the execution of illustrative source code  603 , in accordance with the first illustrative embodiment of the present invention. Illustrative source code  603  is a Java statement that invokes a method setFirstName( ) of object instance  500  with the String argument “John”.  
         [0060]      FIG. 6  also depicts illustrative source code  604 , which comprises an illustrative implementation of method setFirstName( ). This implementation: 
        takes a String argument and copies the argument into object instance  500 &#39;s field firstName; and     invokes UserAlias bean  502 &#39;s setFirstName( ) method with the String argument.          
         [0063]      FIG. 7  depicts object instances  500 ,  501 - 1 , and  502 , as well as a new object instance  501 - 2 , after the execution of illustrative source code  703 , in accordance with the first illustrative embodiment of the present invention. Object instance  501 - 2  is an instance of class  301  that is created as a result of the execution of illustrative source code  703 . Illustrative source code  802  is a Java statement that invokes a method setEmailAddr( ) of object instance  500  with the String argument “john52@aol.com”.  
         [0064]      FIG. 7  also depicts illustrative source code  704 , which comprises an illustrative implementation of method setEmailAddr( ). This implementation: 
        takes a String argument and copies the argument into object instance  500 &#39;s field emailAddr;     creates UserAlias bean  501 - 2 , whose alias is the email address;     sets the value of the foreign key of UserAlias bean  501 - 2  to the internal key of UserTarget bean  502 .          
         [0068]      FIG. 8  depicts object instances  500 ,  501 - 1 ,  501 - 2 , and  502 , as well as a new object instance  501 - 3 , after the execution of illustrative source code  803 , in accordance with the first illustrative embodiment of the present invention. Object instance  501 - 3  is an instance of class  301  that is created as a result of the execution of illustrative source code  803 . Illustrative source code  803  is a Java statement that invokes a method setPhoneNum( ) of object instance  500  with the String argument “555-555-5555”.  
         [0069]      FIG. 8  also depicts illustrative source code  804 , which comprises an illustrative implementation of method setPhoneNum( ). This implementation: 
        takes a String argument and copies the argument into object instance  500 &#39;s field phoneNum;     creates UserAlias bean  501 - 3 , whose alias is the phone number;     sets the value of the foreign key of UserAlias bean  501 - 3  to the internal key of UserTarget bean  502 .          
         [0073]     In accordance with the first illustrative embodiment, class  300  provides three finder methods for finding instances of class  300  based on the value of a key: 
        static User findBySsn(String ssn)     static User findByEmailAddress(String emailAddr)     static User findByPhoneNumber(String phoneNum) 
 
 (The keyword “static” indicates that the methods belong to class  300 , rather than instances of class  300 ). Each of the finder methods above invokes the EJB finder method of UserAliasBean with the specified key value as argument, and UserAliasBean&#39;s EJB finder method in turn invokes the EJB finder method of UserTargetBean with the foreignKey value as argument. A new User instance can then be created and instantiated with the data from the retrieved UserAliasBean and UserTargetBean. 
       
 
         [0077]     As will be appreciated by those skilled in the art, class  300  can also have data accessor methods (i.e., get methods) and “business” methods—as object classes typically do—and it will be clear to those skilled in the art, after reading this disclosure, how to make and use such embodiments of class  300 .  
         [0078]     As will further be appreciated by those skilled in the art, in accordance with the first illustrative embodiment there is a variety of options for handling the destruction of object instances (or “garbage collection”). In some embodiments in which class  300  is defined in a programming language that supports destructors (e.g., C++, etc.), class  300  might have a destructor for destroying instances of the class. In some other embodiments—including those that use a programming language with no destructors (e.g., Java, etc.)—class  300  might have unset methods (e.g., unsetEmailAddr( ), etc.) that 
        (a) determine the number N of associated instances of class  301 ; and     (b) when N&gt;1: 
            destroy the instance of class  301  associated with the particular field (e.g., field emailAddr for method unsetEmailAddr( ), etc.), and     clear the value of the particular field in the instance of class  300 ;    
            otherwise (N=1): 
            identify the single associated instance of class  301 ,     identify the single associated instance of class  302 ,     destroy the instance of class  302 ,     destroy the instance of class  301 ,     clear the value of the particular field in the instance of class  300 , and     mark the instance of class  300  as ready for garbage collection.    
               
 
         [0090]     As will be appreciated by those skilled in the art, in some embodiments, the destruction of instances of class  302  and  301  by an unset method might be subject to object locking via a transaction or some other means of concurrency control. Furthermore, some embodiments of the present invention that use a programming language with support for destructors might define class  300  to have both a destructor and one or more unset methods.  
         [0091]      FIG. 9  depicts three illustrative object classes, in accordance with the second illustrative embodiment of the present invention.  
         [0092]     Object classes  300  and  302  are carried over from the first illustrative embodiment.  
         [0093]     Object class  901  is an entity bean class named UserAliasesBean that is similar to class  301  (UserAliasBean) except that its key field, named aliases instead of alias, is a set that is capable of storing a plurality of aliases (i.e., any two or all three of the user&#39;s social security number, email address, and phone number).  
         [0094]      FIG. 10  depicts object instances of class  300 ,  901 , and  302  and illustrative source code  1003  and  1004 , in accordance with the second illustrative embodiment of the present invention. Object instances  1000 ,  1001 - 1 , and  1002  are instances of class  300 ,  901 , and  302 , respectively, that are created as a result of the execution of illustrative source code  1003 . As shown in  FIG. 10 , illustrative source code  1003  creates object instance  1000  via a conventional Java constructor. It will be appreciated by those skilled in the art that in some other embodiments of the present invention, source code  1003  might instead create object instance  1000  via a factory pattern (e.g., when object instance  1000  is a session Enterprise JavaBean, etc.).  
         [0095]      FIG. 10  also depicts illustrative source code  1004 , which comprises an illustrative implementation of the User( ) constructor in accordance with the second illustrative embodiment. This implementation: 
        takes a String argument that corresponds to social security number, and copies the argument into object instance  1000 &#39;s field ssn;     creates UserAliases bean  1001 - 1  with its aliases field initialized to a singleton containing the social security number;     creates UserTarget bean  1002 ; and     sets the value of the foreign key of UserAliases bean  1001 - 1  to the internal key of UserTarget bean  1002 .          
         [0100]      FIG. 11  depicts object instances  1000  and  1002  and new object instance  1001 - 2  after the execution of illustrative source  1103 , in accordance with the second illustrative embodiment of the present invention. Illustrative source code  1103  is a Java statement that invokes a method setEmailAddr( ) of object instance  1000  with the String argument “john52@aol.com”.  
         [0101]      FIG. 11  also depicts illustrative source code  1104 , which comprises an illustrative implementation of method setEmailAddr( ) of object instance  1000 . This implementation: 
        takes a String argument and copies the argument into object instance  1000 &#39;s field emailAddr;     invokes UserAliases bean  1001 - 1 &#39;s setEmailAddr( ) method with the String argument, which creates a new UserAliases bean  1001 - 2  (see below);     sets variable temp to point to UserAliases bean  1001 - 2 ;     deletes the EJB (and its corresponding database record) currently referenced by variable u 1 aliases (i.e., bean  1001 - 1 ) and     sets variable u 1 aliases to point to new UserAliases bean  1001 - 2 .          
         [0107]      FIG. 11  further depicts illustrative source code  1105 , which comprises an illustrative implementation of method setEmailAddr( ) of object instance  1001 - 1 . This implementation: 
        takes a String argument a;     creates an instance s of a class AliasSet that is a subclass of Set with additional methods for manipulating social security numbers, email addresses, and phone numbers;     initializes the value of s to the set of aliases of object instance  1001 - 1 ;     adds a to s (or if s already had an email address, replaces the old address with a);     creates a new UserAlias bean  1001 - 2  (referred to locally as x) with field aliases set to s;     sets the foreign key of bean  1001 - 2  to the foreign key of bean  1001 - 1 ; and     returns new UserAlias bean  1001 - 2 .          
         [0115]      FIG. 12  depicts object instances  1000  and  1002  and new object instance  1001 - 3  after the execution of illustrative source code  1203 , in accordance with the second illustrative embodiment of the present invention.  
         [0116]     Illustrative source code  1203  is a Java statement that invokes a method setPhoneNum( ) of object instance  1000  with the String argument “555-555-5555”.  
         [0117]      FIG. 12  also depicts illustrative source code  1204 , which comprises an illustrative implementation of method setPhoneNum( ) of object instance  1000 . This implementation: 
        takes a String argument and copies the argument into object instance  1000 &#39;s field phoneNum; and     invokes UserAliases bean  1001 - 2 &#39;s setPhoneNum( ) method with the String argument, which creates a new UserAliases bean  1001 - 3  (see below);     sets variable temp to point to UserAliases bean  1001 - 3 ;     deletes the EJB (and its corresponding database record) currently referenced by variable u 1 aliases (i.e., bean  1001 - 2 ) and     sets variable u 1 aliases to point to new UserAliases bean  1001 - 3 .          
         [0123]      FIG. 12  further depicts illustrative source code  1205 , which comprises an illustrative implementation of method setPhoneNum( ) of object instance  1001 - 2 . This implementation: 
        takes a String argument a;     creates an instance s of class AliasSet;     initializes the value of s to the set of aliases of object instance  1001 - 2 ;     adds a to s (or if s already had a phone number, replaces the old phone number with a);     creates a new UserAlias bean  1001 - 3  (referred to locally as x) with field aliases set to s;     sets the foreign key of bean  1001 - 3  to the foreign key of bean  1001 - 2 ; and     returns UserAlias bean  1001 - 3 .          
         [0131]     In accordance with the second illustrative embodiment, class  500  provides the same three finder methods as class  300  of the first illustrative embodiment: 
        static User findBySsn(String ssn)     static User findByEmailAddress(String emailAddr)     static User findByPhoneNumber(String phoneNum) 
 
 Each of these finder methods works the same way as in the first illustrative embodiment (i.e., by invoking the EJB finder method of UserAliasBean with the specified key value as argument, which in turn invokes the EJB finder method of UserTargetBean with the foreignKey value as argument, and creating a new User instance based on the retrieved UserAliasBean and UserTargetBean. 
       
 
         [0135]     As will be appreciated by those skilled in the art, class  300  can also have data accessor methods (i.e., get methods) and “business” methods—as object classes typically do—and it will be clear to those skilled in the art, after reading this disclosure, how to make and use such embodiments of class  300 .  
         [0136]     As will further be appreciated by those skilled in the art, in accordance with the second illustrative embodiment there is a variety of options for handling the destruction of object instances (or “garbage collection”). In some embodiments in which class  300  is defined in a programming language that supports destructors (e.g., C++, etc.), class  300  might have a destructor for destroying instances of the class. In some other embodiments—including those that use a programming language with no destructors (e.g., Java, etc.)—class  300  might have unset methods (e.g., unsetEmailAddr( ), etc.) that 
        (a) navigate to field aliases of the single associated instance of class  901 ; and     (b) when aliases has two or more elements: 
            delete the appropriate element from aliases, and     clear the value of the appropriate field in the instance of class  300 ;    
            otherwise (aliases has one element): 
            identify the single associated instance of class  302 ,     destroy the instance of class  302 ,     destroy the instance of class  901 ,     clear the value of the particular field in the instance of class  300 , and     mark the instance of class  300  as ready for garbage collection.    
               
 
         [0147]     As will be appreciated by those skilled in the art, in some embodiments, the destruction of instances of class  302  and  901  by an unset method might be subject to object locking via a transaction or some other means of concurrency control. Furthermore, some embodiments of the present invention that use a programming language with support for destructors might define class  300  to have both a destructor and one or more unset methods.  
         [0148]      FIG. 13  depicts three illustrative object classes, in accordance with the third illustrative embodiment of the present invention.  
         [0149]     Object classes  901  and  302  are carried over from the second illustrative embodiment.  
         [0150]     Object class  1300  is named User and is similar to class  300  (also named User), except that class  300 &#39;s mutable key fields ssn, emailAddr, and phoneNum have been replaced with a single mutable key field aliases that is capable of storing a plurality of aliases. In the third illustrative embodiment, not only is the key field aliases in both classes  1300  and  901  capable of storing a social security number, an email address, and a phone number, but they are also capable of storing multiple phone numbers and email addresses (e.g., office and mobile phone numbers, personal and business email addresses, etc.), where each of the phone numbers and email addresses uniquely identifies an object instance.  
         [0151]     In accordance with the third illustrative embodiment, object class  1300  is, like class  300 , a regular Java class. However, it will be clear to those skilled in the art how to make and use alternative embodiments in which class  1300  is a session Enterprise JavaBean, or an inner class of a Java servlet, or some other kind of class.  
         [0152]      FIG. 14  depicts object instances of class  1300 ,  901  and  302  and illustrative source code  1403  and  1404 , in accordance with the third illustrative embodiment of the present invention. Object instances  1400 ,  1401 - 1 , and  1402  are instances of class  1300 ,  901 , and  302 , respectively, that are created as a result of the execution of illustrative source code  1403 . As shown in  FIG. 14 , illustrative source code  1403  creates object instance  1400  via a conventional Java constructor. It will be appreciated by those skilled in the art that in some other embodiments of the present invention, source code  1403  might instead create object instance  1000  via a factory pattern (e.g., when object instance  1400  is a session Enterprise JavaBean, etc.).  
         [0153]      FIG. 14  also depicts illustrative source code  1404 , which comprises an illustrative implementation of the User( ) constructor in accordance with the third illustrative embodiment. This implementation: 
        takes a String argument that corresponds to social security number;     adds the argument to object instance  1400 &#39;s field aliases, which was initialized to the empty set;     creates UserAliases bean  1401 - 1  with its aliases field initialized to a singleton containing the social security number;     creates UserTarget bean  1402 ; and     sets the value of the foreign key of UserAliases bean  1001 - 1  to the internal key of UserTarget bean  1002 .          
         [0159]      FIG. 15  depicts object instances  1400  and  1402  and new object instance  1401 - 2  after the execution of illustrative source code  1403 , in accordance with the third illustrative embodiment of the present invention. Illustrative source code  1503  is a Java statement that invokes a method addAlias( ) of object instance  1400  with the String argument “john52@aol.com”.  
         [0160]      FIG. 15  also depicts illustrative source code  1504 , which comprises an illustrative implementation of method addAlias( ) of object instance  1400 . This implementation: 
        takes a String argument and adds the argument to object instance  1400 &#39;s field aliases;     invokes UserAliases bean  1401 - 1 &#39;s addAlias( ) method with the String argument, which creates a new UserAliases bean  1401 - 2  (see below);     sets variable temp to point to UserAliases bean  1401 - 2 ;     deletes the EJB (and its corresponding database record) currently referenced by variable u 1 aliases (i.e., bean  1401 - 1 ) and     sets variable u 1 aliases to point to new UserAliases bean  1401 - 2 .          
         [0166]      FIG. 15  further depicts illustrative source code  1505 , which comprises an illustrative implementation of method addAlias( ) of object instance  1401 - 1 . This implementation: 
        takes a String argument a;     sets variable s to the union of 
            (i) the current aliases of object instance  1401 - 1 , and     (ii) set {a};    
            creates a new UserAlias bean  1401 - 2  (referred to locally as x) with field aliases set to s;     sets the foreign key of bean  1401 - 2  to the foreign key of bean  1401 - 1 ; and     returns new UserAlias bean  1401 - 2 .          
         [0174]      FIG. 16  depicts object instances  1400  and  1402  and new object instance  1401 - 3  after the execution of illustrative source code  1603 , in accordance with the third illustrative embodiment of the present invention. Illustrative source code  1603  invokes method addAlias( ) of object instance  1400  with the String argument “555-555-5555”, which executes in similar fashion as source code  1503 .  
         [0175]      FIG. 17  depicts object instances  1400  and  1402  and new object instance  1401 - 4  after the execution of illustrative source code  1703 , in accordance with the third illustrative embodiment of the present invention. Illustrative source code  1703  is a Java statement that invokes a method changeAlias( ) of object instance  1400  with the String arguments “john52@aol.com” and “jcarter@nih.gov”.  
         [0176]      FIG. 17  also depicts illustrative source code  1704 , which comprises an illustrative implementation of method changeAlias( ) of object instance  1400 . This implementation: 
        takes String arguments a 1  and a 2 ;     deletes a 1  from object instance  1400 &#39;s field aliases (if a 1  is not an alias of object instance  1400 , then an AliasNotFoundException is thrown);     adds a 2  to object instance  1400 &#39;s field aliases;     invokes UserAliases bean  1401 - 3 &#39;s changeAlias( ) method with arguments a 1  and a 2 , which creates a new UserAliases bean  1401 - 4  (see below);     sets variable temp to point to UserAliases bean  1401 - 4 ;     deletes the EJB (and its corresponding database record) currently referenced by variable u 1 aliases (i.e., bean  1401 - 3 ) and     sets variable u 1 aliases to point to new UserAliases bean  1401 - 4 .          
         [0184]      FIG. 17  further depicts illustrative source code  1705 , which comprises an illustrative implementation of method changeAlias( ) of object instance  1401 - 3 . This implementation: 
        takes String arguments a 1  and a 2 ;     initializes variable s to the set of aliases of object instance  1401 - 3 ;     deletes string a 1  from set s;     adds string a 2  to set s;     creates a new UserAlias bean  1401 - 4  (referred to locally as x) with field aliases set to s;     sets the foreign key of bean  1401 - 4  to the foreign key of bean  1401 - 3 ; and     returns new UserAlias bean  1401 - 4 .          
         [0192]      FIG. 18  depicts object instances  1400  and  1402  and new object instance  1401 - 5  after the execution of illustrative source code  1803 , in accordance with the third illustrative embodiment of the present invention. Illustrative source code  1803  is a Java statement that invokes a method deleteAlias( ) of object instance  1400  with a String argument “555-555-5555”.  
         [0193]      FIG. 18  also depicts illustrative source code  1804 , which comprises an illustrative implementation of method deleteAlias( ) of object instance  1400 . This implementation: 
        takes a String argument a;     deletes a from object instance  1400 &#39;s field aliases (if a is not an alias of object instance  1400 , then an AliasNotFoundException is thrown);     invokes UserAliases bean  1401 - 4 &#39;s deleteAlias( ) method with argument a, which creates a new UserAliases bean  1401 - 5  (see below);     sets variable temp to point to UserAliases bean  1401 - 5 ;     deletes the EJB (and its corresponding database record) currently referenced by variable u 1 aliases (i.e., bean  1401 - 4 ) and     sets variable u 1 aliases to point to new UserAliases bean  1401 - 5 .          
         [0200]      FIG. 18  further depicts illustrative source code  1805 , which comprises an illustrative implementation of method deleteAlias( ) of object instance  1401 - 4 . This implementation: 
        takes String argument a;     initializes variable s to the set of aliases of object instance  1401 - 4 ;     deletes string a from set s;     creates a new UserAlias bean  1401 - 5  (referred to locally as x) with field aliases set to s;     sets the foreign key of bean  1401 - 5  to the foreign key of bean  1401 - 4 ; and     returns new UserAlias bean  1401 - 5 .          
         [0207]      FIG. 19  depicts object instances  1400  and  1402  and new object instance  1401 - 6  after the execution of illustrative source code  1603 , in accordance with the third illustrative embodiment of the present invention. Illustrative source code  1603  invokes method addAlias( ) of object instance  1400  with the String argument “DNA@gmail.com”, which executes in similar fashion as source code  1503  and  1603 . Thus in the third illustrative embodiment of the present invention, it is possible for a user to have a plurality of email address aliases. It will be clear to those skilled in the art how to augment the third illustrative embodiment to allow only one social security number alias per user, while still permitting multiple aliases for other types of information (e.g., email addresses, phone numbers, etc.).  
         [0208]     In some operating environments the third illustrative embodiment enjoys a performance advantage over the first and second illustrative embodiments. However, the third illustrative embodiment has the following disadvantage: an implementation for finder methods based on a single key value (i.e., a social security number or an email address or a phone number) cannot simply invoke the EJB finder method of UserAliases, as is done in the first and second illustrative embodiments. For example, in accordance with the third illustrative embodiment, implementing such finder methods for User (e.g., findBySsn, findByEmailAddress, findByPhoneNumber, etc.) requires one or more queries to determine whether a given key value is contained in the aliases field of UserAliases bean instances.  
         [0209]     As will be appreciated by those skilled in the art, class  1300  can also have data accessor methods (i.e., get methods) and “business” methods—as object classes typically do—and it will be clear to those skilled in the art, after reading this disclosure, how to make and use such embodiments of class  1300 .  
         [0210]     As will further be appreciated by those skilled in the art, in accordance with the third illustrative embodiment there is a variety of options for handling the destruction of object instances (or “garbage collection”). In some embodiments in which class  1300  is defined in a programming language that supports destructors (e.g., C++, etc.), class  1300  might have a destructor for destroying instances of the class. In some other embodiments—including those that use a programming language with no destructors (e.g., Java, etc.)—class  1300  might have unset methods (e.g., unsetEmailAddr( ), etc.) that 
        (a) navigate to field aliases of the single associated instance of class  901 ; and     (b) when aliases has two or more elements: 
            delete the appropriate element from aliases, and     delete the same element from field aliases of the instance of class  1300 ;    
            otherwise (aliases has one element): 
            identify the single associated instance of class  302 ,     destroy the instance of class  302 ,     destroy the instance of class  901 ,     set field aliases of the instance of class  1300  to the empty set, and     mark the instance of class  1300  as ready for garbage collection.    
               
 
         [0221]     As will be appreciated by those skilled in the art, in some embodiments, the destruction of instances of class  302  and  901  by an unset method might be subject to object locking via a transaction or some other means of concurrency control. Furthermore, some embodiments of the present invention that use a programming language with support for destructors might define class  1300  to have both a destructor and one or more unset methods.  
         [0222]     As will also be appreciated by those skilled in the art, in some embodiments of the present invention—whether in accordance with the first, second, or third illustrative embodiments—it might be advantageous for the “behind-the-scenes” Enterprise JavaBean classes and instances (e.g., classes  301  and  302  and their instances, etc.), as well as the code for creating and manipulating these classes and instances, to be automatically generated (e.g., by an application server, by an integrated development environment, etc.) rather than hand-coded by a developer. In such embodiments, a developer might create the “front-end” classes and instances (e.g., class  300  and its instances, etc.) and not even be aware of the existence of the behind-the-scenes classes and instances that are automatically generated.  
         [0223]     It is to be understood that the above-described embodiments are merely illustrative of the present invention and that many variations of the above-described embodiments can be devised by those skilled in the art without departing from the scope of the invention. For example, in this Specification, numerous specific details are provided in order to provide a thorough description and understanding of the illustrative embodiments of the present invention. Those skilled in the art will recognize, however, that the invention can be practiced without one or more of those details, or with other methods, materials, components, etc.  
         [0224]     Furthermore, in some instances, well-known structures, materials, or operations are not shown or described in detail to avoid obscuring aspects of the illustrative embodiments. It is understood that the various embodiments shown in the Figures are illustrative, and are not necessarily drawn to scale. Reference throughout the specification to “one embodiment” or “an embodiment” or “some embodiments” means that a particular feature, structure, material, or characteristic described in connection with the embodiment(s) is included in at least one embodiment of the present invention, but not necessarily all embodiments. Consequently, the appearances of the phrase “in one embodiment,” “in an embodiment,” or “in some embodiments” in various places throughout the Specification are not necessarily all referring to the same embodiment. Furthermore, the particular features, structures, materials, or characteristics can be combined in any suitable manner in one or more embodiments. It is therefore intended that such variations be included within the scope of the following claims and their equivalents.