Use @JoinField to define a structured data type's foreign key field for an object mapped to NoSql data.
Table 2-29 describes this annotation's elements.
Table 2-29 @JoinField Annotation Elements
| Annotation Element | Description | Default |
|---|---|---|
|
|
(Optional) The name of the foreign key/ID reference field in the source record. |
|
|
|
(Optional) The name of the ID field in the target record. |
The @JoinField annotation is a generic form of the @JoinColumn annotation, which is not specific to relational databases. You can use @JoinField to map EIS and NoSQL data.
These examples show how to use this extension as an annotation and in XML.
Example 2-54 Using @JoinField Annotation
@Entity
@NoSql
public class Order {
...
@ManyToOne
@JoinField(name="customerId")
private Customer customer;
}
Example 2-55 Using <join-field> in XML
<entity name="Order" class="org.acme.Order">
<no-sql/>
...
<many-to-one name="customer">
<join-field name="customerId"/>
</many-to-one>
</entity>
For more information, see: