Use this interface when zero or one secondary key is present in a single primary record, in other words, for many-to-one and one-to-one relationships. When more than one secondary key may be present (for many-to-many and one-to-many relationships), use the {@link SecondaryMultiKeyCreator} interface instead. The table below summarizes howto create all four variations of relationships.
Relationship | Interface | Duplicates | Example |
---|---|---|---|
One-to-one | {@link SecondaryKeyCreator} | No | A person record with a unique social security number key. |
Many-to-one | {@link SecondaryKeyCreator} | Yes | A person record with a non-unique employer key. |
One-to-many | {@link SecondaryMultiKeyCreator} | No | A person record with multiple unique email address keys. |
Many-to-many | {@link SecondaryMultiKeyCreator} | Yes | A person record with multiple non-unique organization keys. |
To configure a database for duplicates. pass true to {@link DatabaseConfig#setSortedDuplicates}.
WARNING: Key creator instances are shared by multiple threads and key creator methods are called without any special synchronization. Therefore, key creators must be thread safe. In general no shared state should be used and any caching of computed values must be done with proper synchronization.
|
|
|
|