Use @CompositeMember
to indicate that a class belongs to a composite persistence unit.
It should be used if target type is a primitive type and @CollectionTable
designates the table that belongs to composite member persistence unit other than the source composite member persistence unit. This allows the source and target to be mapped to different databases.
Table 2-12 describes this annotation's elements.
Table 2-12 @CompositeMember Annotation Elements
Annotation Element | Description | Default |
---|---|---|
|
The name of a target composite member persistence unit to which element table belongs (if differs from source composite member persistence unit). |
The @CompositeMember
annotation is ignored unless it is in a composite member persistence unit. It may be used in conjunction with @ElementCollection
and @CollectionTable
annotations.
You can configure the CompositeMember
using annotations or the eclipselink-orm.xml
file, as shown in these examples.
Example 2-27 Using @CompositeMember Annotation
@ElementCollection()
@CollectionTable(name = "MBR1_RESPONS", joinColumns=@JoinColumn(name="EMP_ID"))
@CompositeMember("branch-database")
@Column(name = "DESCRIPTION")
public Collection<String> getResponsibilities() {
return responsibilities;
}
Example 2-28 Using <composite-member> XML
<element-collection name="responsibilities" composite-member="branch-database">
<column name="DESCRIPTION"/>
<collection-table name="XML_MBR3_RESPONS">
<join-column name="EMP_ID"/>
</collection-table>
</element-collection>
For more information, see:
"Using Multiple Databases with a Composite Persistence Unit" in Solutions Guide for Oracle TopLink