Example: Configuring the IDResolveKeys.properties file to generate identifiers

In the following example, you need to resolve identifiers ADDRBOOK_ID and ADDRESS_ID for ADDRBOOK and ADDRESS records respectively. The identifiers for the MEMBER records are already known. Each record requires a valid identifier for the WebSphere Commerce database. In addition, the ADDRBOOK_ID in the ADDRESS record requires the identifier from the primary table to satisfy its foreign-key constraint.


  <MEMBER
    MEMBER_ID="100"
    TYPE="U"
    STATE="1"
  />
  <MEMBER
    MEMBER_ID="101"
    TYPE="U"
    STATE="1"
  />
  <ADDRBOOK
    MEMBER_ID="100"
    DISPLAYNAME="Friends"            
Actual value of the DISPLAYNAME column
    DESCRIPTION="All my friends"
    TYPE="P"
  />
  <ADDRESS
    ADDRBOOK_ID="@Friends"           
Refers to the ADDRBOOK using the DISPLAYNAME 
                                     value as a lookup
    MEMBER_ID="101"
    NICKNAME="Bob"
    ADDRESS1="15 Brave Developers St."
    CITY="Toronto"
    ZIPCODE="A0A0A0"
    COUNTRY="Canada"
    STATUS="P"
  />

You need a IDResolveKeys.properties file to identify which columns in the primary row will be used by the relationship rows in resolving the identifier for the foreign-key column. The following procedure ensures that parsing of the preceding file proceeds correctly.

In IdResolveKeys.properties, specify the following:


  NAMEDELIMITER=@
  SELECTDELIMITER=:

  ADDRBOOK=@DISPLAYNAME:DISPLAYNAME
  ADDRESS=@NICKNAME:NICKNAME

NAMEDELIMITER and SELECTDELIMITER set the delimiters used throughout the IDResolveKeys.properties file, and they must be used consistently.

ADDRBOOK=@DISPLAYNAME:DISPLAYNAME states that when an address-book record is received, the identifier for the address-book row is created. The DISPLAYNAME field is extracted from the input record and used to form an association to the new identifier. The DISPLAYNAME string is used to match the address-book row DISPLAYNAME and resolve the identifier needed by the foreign key.

Using the previous input example, in which the DISPLAYNAME is Friends, assume that the identifier created for this record is 12951. The DISPLAYNAME is used as a key look-aside for 12951. Processing continues with the next record, ADDRESS, where ADDRBOOK_ID has the form of "@..." (which indicates that what follows the delimiter is to be used for looking up the address-book identifier). The string matches the DISPLAYNAME, and 12951 is returned and placed in the ADDRBOOK_ID attribute.


  <MEMBER
    MEMBER_ID="100"
    TYPE="U"
    STATE="1"
  />
  <MEMBER
    MEMBER_ID="101"
    TYPE="U"
    STATE="1"
  />
  <ADDRBOOK
    ADDRBOOK_ID="12951"                  
Generated primary key
    MEMBER_ID="100"
    DISPLAYNAME="Friends"                
Value of ADDRBOOK DISPLAYNAME unchanged
    DESCRIPTION="All my friends"
    TYPE="P"
  />
  <ADDRESS
    ADDRESS_ID="13051"                   
Generated primary key
    ADDRBOOK_ID="12951"                  
ADDRESS refers to correct ADDRBOOK
    MEMBER_ID="101"
    NICKNAME="Bob"
    ADDRESS1="15 Brave Developers St."
    CITY="Toronto"
    ZIPCODE="A0A0A0"
    COUNTRY="Canada"
    STATUS="P"
  />