Java Persistence API (JPA) Extensions Reference for EclipseLink, Release 2.4
  Go To Table Of Contents
 Search
 PDFComments
Comments


@CompositeMember

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.


Annotation Elements

Table 2-12 describes this annotation's elements.

Table 2-12 @CompositeMember Annotation Elements

Annotation Element Description Default

value

The name of a target composite member persistence unit to which element table belongs (if differs from source composite member persistence unit).




Usage

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.


Examples

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>


See Also

For more information, see: