Interface ReferenceMappingSetup

public interface ReferenceMappingSetup

The ReferenceMappingSetup is the base configuration used to define which fields should be read from a source entity in an EntityMapping to construct a reference to a destination entity. The source fields will be used for querying uniVocity's metadata to restore values associated with the identifier of an entity. For example:

 //Maps fields "nbr" and "seq" from the source entity "WGT" to a destination entity "weight"

 EntityMapping weightMapping ="WGT", "weight");
 weightMapping.identity().associate("nbr", "seq").toGeneratedId("gid");

When the above mapping is executed, values read from nbr and seq will be associated with the generated identifier gid:
 Source entity (WGT)    Destination entity (weight)
     nbr | seq                    gid
     ----+----                  -------
     001 | 1                       1
     001 | 2                       2
     002 | 1                       3

With this information on the metadata, a reference mapping can be defined as:
 //Uses fields "wgt_nbr" and "wgt_seq" from the source entity "WGT_DET" to obtain the identifier associated with "weight".
 //After getting the correct identifier of "weight", copy it to "weight_ref"

 EntityMapping weightDetails ="WGT_DET", "weight_details");
 weightDetails.reference().using("wgt_nbr", "wgt_seq").referTo("WGT", "weight").on("weight_ref");

Using the above mapping, uniVocity will execute a query against its metadata requesting any values associated with wgt_nbr and wgt_seq, where the source entity is WGT and the destination entity is weight. The returned identifiers for weight will then be associated with the weight_ref field of weight_details

uniVocity Software Pty Ltd -
See Also:
EntityMapping, IdentifierMappingSetup

Method Summary
 ReferencedEntity using(String... sourceFields)
          Associates one or more fields from the source entity in an EntityMapping with a reference in the destination entity.

Method Detail


ReferencedEntity using(String... sourceFields)
Associates one or more fields from the source entity in an EntityMapping with a reference in the destination entity.

sourceFields - the field names in the source entity to be associated with a reference to an entity in the destination. Expressions are allowed within curly braces (i.e. "{expression}")
the next step of this configuration: define what source entity has an identifier mapped with the given fields, and what entity in the destination had its identifier associated with these fields (using IdentifierMappingSetup).

Copyright © 2015 uniVocity Software Pty Ltd. All rights reserved.