| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> |
| <!-- NewPage --> |
| <html lang="en"> |
| <head> |
| <title>AssociationOverride</title> |
| <link rel="stylesheet" type="text/css" href="../../stylesheet.css" title="Style"> |
| <script type="text/javascript" src="../../script.js"></script> |
| </head> |
| <body> |
| <script type="text/javascript"><!-- |
| try { |
| if (location.href.indexOf('is-external=true') == -1) { |
| parent.document.title="AssociationOverride"; |
| } |
| } |
| catch(err) { |
| } |
| //--> |
| </script> |
| <noscript> |
| <div>JavaScript is disabled on your browser.</div> |
| </noscript> |
| <!-- ========= START OF TOP NAVBAR ======= --> |
| <div class="topNav"><a name="navbar.top"> |
| <!-- --> |
| </a> |
| <div class="skipNav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div> |
| <a name="navbar.top.firstrow"> |
| <!-- --> |
| </a> |
| <ul class="navList" title="Navigation"> |
| <li><a href="../../overview-summary.html">Overview</a></li> |
| <li><a href="package-summary.html">Package</a></li> |
| <li class="navBarCell1Rev">Class</li> |
| <li><a href="package-tree.html">Tree</a></li> |
| <li><a href="../../deprecated-list.html">Deprecated</a></li> |
| <li><a href="../../index-all.html">Index</a></li> |
| <li><a href="../../help-doc.html">Help</a></li> |
| </ul> |
| </div> |
| <div class="subNav"> |
| <ul class="navList"> |
| <li><a href="../../javax/persistence/AccessType.html" title="enum in javax.persistence"><span class="typeNameLink">Prev Class</span></a></li> |
| <li><a href="../../javax/persistence/AssociationOverrides.html" title="annotation in javax.persistence"><span class="typeNameLink">Next Class</span></a></li> |
| </ul> |
| <ul class="navList"> |
| <li><a href="../../index.html?javax/persistence/AssociationOverride.html" target="_top">Frames</a></li> |
| <li><a href="AssociationOverride.html" target="_top">No Frames</a></li> |
| </ul> |
| <ul class="navList" id="allclasses_navbar_top"> |
| <li><a href="../../allclasses-noframe.html">All Classes</a></li> |
| </ul> |
| <div> |
| <script type="text/javascript"><!-- |
| allClassesLink = document.getElementById("allclasses_navbar_top"); |
| if(window==top) { |
| allClassesLink.style.display = "block"; |
| } |
| else { |
| allClassesLink.style.display = "none"; |
| } |
| //--> |
| </script> |
| </div> |
| <div> |
| <ul class="subNavList"> |
| <li>Summary: </li> |
| <li>Field | </li> |
| <li><a href="#annotation.type.required.element.summary">Required</a> | </li> |
| <li><a href="#annotation.type.optional.element.summary">Optional</a></li> |
| </ul> |
| <ul class="subNavList"> |
| <li>Detail: </li> |
| <li>Field | </li> |
| <li><a href="#annotation.type.element.detail">Element</a></li> |
| </ul> |
| </div> |
| <a name="skip.navbar.top"> |
| <!-- --> |
| </a></div> |
| <!-- ========= END OF TOP NAVBAR ========= --> |
| <!-- ======== START OF CLASS DATA ======== --> |
| <div class="header"> |
| <div class="subTitle">javax.persistence</div> |
| <h2 title="Annotation Type AssociationOverride" class="title">Annotation Type AssociationOverride</h2> |
| </div> |
| <div class="contentContainer"> |
| <div class="description"> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <hr> |
| <br> |
| <pre>@Repeatable(value=<a href="../../javax/persistence/AssociationOverrides.html" title="annotation in javax.persistence">AssociationOverrides.class</a>) |
| @Target(value={TYPE,METHOD,FIELD}) |
| @Retention(value=RUNTIME) |
| public @interface <span class="memberNameLabel">AssociationOverride</span></pre> |
| <div class="block">Used to override a mapping for an entity relationship. |
| |
| <p> May be applied to an entity that extends a mapped superclass to |
| override a relationship mapping defined by the mapped |
| superclass. If not specified, the association is mapped the same as |
| in the original mapping. When used to override a mapping defined by |
| a mapped superclass, <code>AssociationOverride</code> is applied to |
| the entity class. |
| |
| <p> May be used to override a relationship mapping from an |
| embeddable within an entity to another entity when the embeddable |
| is on the owning side of the relationship. When used to override a |
| relationship mapping defined by an embeddable class (including an |
| embeddable class embedded within another embeddable class), |
| <code>AssociationOverride</code> is applied to the field or |
| property containing the embeddable. |
| |
| <p> When <code>AssociationOverride</code> is used to override a |
| relationship mapping from an embeddable class, the |
| <code>name</code> element specifies the referencing relationship |
| field or property within the embeddable class. To override mappings |
| at multiple levels of embedding, a dot (".") notation syntax must |
| be used in the <code>name</code> element to indicate an attribute |
| within an embedded attribute. The value of each identifier used |
| with the dot notation is the name of the respective embedded field |
| or property. |
| |
| <p> When <code>AssociationOverride</code> is applied to override |
| the mappings of an embeddable class used as a map value, |
| "<code>value.</code>" must be used to prefix the name of the |
| attribute within the embeddable class that is being overridden in |
| order to specify it as part of the map value. |
| |
| <p> If the relationship mapping is a foreign key mapping, the |
| <code>joinColumns</code> element is used. If the relationship |
| mapping uses a join table, the <code>joinTable</code> element must |
| be specified to override the mapping of the join table and/or its |
| join columns. |
| |
| <pre> |
| Example 1: Overriding the mapping of a relationship defined by a mapped superclass |
| |
| @MappedSuperclass |
| public class Employee { |
| ... |
| @ManyToOne |
| protected Address address; |
| ... |
| } |
| |
| @Entity |
| @AssociationOverride(name="address", |
| joinColumns=@JoinColumn(name="ADDR_ID")) |
| // address field mapping overridden to ADDR_ID foreign key |
| public class PartTimeEmployee extends Employee { |
| ... |
| } |
| </pre> |
| |
| <pre> |
| Example 2: Overriding the mapping for phoneNumbers defined in the ContactInfo class |
| |
| @Entity |
| public class Employee { |
| @Id int id; |
| @AssociationOverride( |
| name="phoneNumbers", |
| joinTable=@JoinTable( |
| name="EMPPHONES", |
| joinColumns=@JoinColumn(name="EMP"), |
| inverseJoinColumns=@JoinColumn(name="PHONE") |
| ) |
| ) |
| @Embedded ContactInfo contactInfo; |
| ... |
| } |
| |
| @Embeddable |
| public class ContactInfo { |
| @ManyToOne Address address; // Unidirectional |
| @ManyToMany(targetEntity=PhoneNumber.class) List phoneNumbers; |
| } |
| |
| @Entity |
| public class PhoneNumber { |
| @Id int number; |
| @ManyToMany(mappedBy="contactInfo.phoneNumbers") |
| Collection<Employee> employees; |
| } |
| </pre></div> |
| <dl> |
| <dt><span class="simpleTagLabel">Since:</span></dt> |
| <dd>Java Persistence 1.0</dd> |
| <dt><span class="seeLabel">See Also:</span></dt> |
| <dd><a href="../../javax/persistence/Embedded.html" title="annotation in javax.persistence"><code>Embedded</code></a>, |
| <a href="../../javax/persistence/Embeddable.html" title="annotation in javax.persistence"><code>Embeddable</code></a>, |
| <a href="../../javax/persistence/MappedSuperclass.html" title="annotation in javax.persistence"><code>MappedSuperclass</code></a>, |
| <a href="../../javax/persistence/AttributeOverride.html" title="annotation in javax.persistence"><code>AttributeOverride</code></a></dd> |
| </dl> |
| </li> |
| </ul> |
| </div> |
| <div class="summary"> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <!-- =========== ANNOTATION TYPE REQUIRED MEMBER SUMMARY =========== --> |
| <ul class="blockList"> |
| <li class="blockList"><a name="annotation.type.required.element.summary"> |
| <!-- --> |
| </a> |
| <h3>Required Element Summary</h3> |
| <table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Required Element Summary table, listing required elements, and an explanation"> |
| <caption><span>Required Elements</span><span class="tabEnd"> </span></caption> |
| <tr> |
| <th class="colFirst" scope="col">Modifier and Type</th> |
| <th class="colLast" scope="col">Required Element and Description</th> |
| </tr> |
| <tr class="altColor"> |
| <td class="colFirst"><code>java.lang.String</code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../javax/persistence/AssociationOverride.html#name--">name</a></span></code> |
| <div class="block">(Required) The name of the relationship property whose mapping is |
| being overridden if property-based access is being used, |
| or the name of the relationship field if field-based access is used.</div> |
| </td> |
| </tr> |
| </table> |
| </li> |
| </ul> |
| <!-- =========== ANNOTATION TYPE OPTIONAL MEMBER SUMMARY =========== --> |
| <ul class="blockList"> |
| <li class="blockList"><a name="annotation.type.optional.element.summary"> |
| <!-- --> |
| </a> |
| <h3>Optional Element Summary</h3> |
| <table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Optional Element Summary table, listing optional elements, and an explanation"> |
| <caption><span>Optional Elements</span><span class="tabEnd"> </span></caption> |
| <tr> |
| <th class="colFirst" scope="col">Modifier and Type</th> |
| <th class="colLast" scope="col">Optional Element and Description</th> |
| </tr> |
| <tr class="altColor"> |
| <td class="colFirst"><code><a href="../../javax/persistence/ForeignKey.html" title="annotation in javax.persistence">ForeignKey</a></code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../javax/persistence/AssociationOverride.html#foreignKey--">foreignKey</a></span></code> |
| <div class="block">(Optional) Used to specify or control the generation of a |
| foreign key constraint for the columns corresponding to the |
| <code>joinColumns</code> element when table generation is in |
| effect.</div> |
| </td> |
| </tr> |
| <tr class="rowColor"> |
| <td class="colFirst"><code><a href="../../javax/persistence/JoinColumn.html" title="annotation in javax.persistence">JoinColumn</a>[]</code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../javax/persistence/AssociationOverride.html#joinColumns--">joinColumns</a></span></code> |
| <div class="block">The join column(s) being mapped to the persistent attribute(s).</div> |
| </td> |
| </tr> |
| <tr class="altColor"> |
| <td class="colFirst"><code><a href="../../javax/persistence/JoinTable.html" title="annotation in javax.persistence">JoinTable</a></code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../javax/persistence/AssociationOverride.html#joinTable--">joinTable</a></span></code> |
| <div class="block">The join table that maps the relationship.</div> |
| </td> |
| </tr> |
| </table> |
| </li> |
| </ul> |
| </li> |
| </ul> |
| </div> |
| <div class="details"> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <!-- ============ ANNOTATION TYPE MEMBER DETAIL =========== --> |
| <ul class="blockList"> |
| <li class="blockList"><a name="annotation.type.element.detail"> |
| <!-- --> |
| </a> |
| <h3>Element Detail</h3> |
| <a name="name--"> |
| <!-- --> |
| </a> |
| <ul class="blockListLast"> |
| <li class="blockList"> |
| <h4>name</h4> |
| <pre>public abstract java.lang.String name</pre> |
| <div class="block">(Required) The name of the relationship property whose mapping is |
| being overridden if property-based access is being used, |
| or the name of the relationship field if field-based access is used.</div> |
| </li> |
| </ul> |
| </li> |
| </ul> |
| <!-- ============ ANNOTATION TYPE MEMBER DETAIL =========== --> |
| <ul class="blockList"> |
| <li class="blockList"><a name="joinColumns--"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>joinColumns</h4> |
| <pre>public abstract <a href="../../javax/persistence/JoinColumn.html" title="annotation in javax.persistence">JoinColumn</a>[] joinColumns</pre> |
| <div class="block">The join column(s) being mapped to the persistent attribute(s). |
| The <code>joinColumns</code> elements must be specified if a |
| foreign key mapping is used in the overriding of the mapping of |
| the relationship. The <code>joinColumns</code> element must |
| not be specified if a join table is used in the overriding of |
| the mapping of the relationship.</div> |
| <dl> |
| <dt>Default:</dt> |
| <dd>{}</dd> |
| </dl> |
| </li> |
| </ul> |
| </li> |
| </ul> |
| <ul class="blockList"> |
| <li class="blockList"><a name="foreignKey--"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>foreignKey</h4> |
| <pre>public abstract <a href="../../javax/persistence/ForeignKey.html" title="annotation in javax.persistence">ForeignKey</a> foreignKey</pre> |
| <div class="block">(Optional) Used to specify or control the generation of a |
| foreign key constraint for the columns corresponding to the |
| <code>joinColumns</code> element when table generation is in |
| effect. If both this element and the <code>foreignKey</code> |
| element of any of the <code>joinColumns</code> elements are |
| specified, the behavior is undefined. If no foreign key |
| annotation element is specified in either location, the |
| persistence provider's default foreign key strategy will |
| apply.</div> |
| <dl> |
| <dt><span class="simpleTagLabel">Since:</span></dt> |
| <dd>Java Persistence 2.1</dd> |
| </dl> |
| <dl> |
| <dt>Default:</dt> |
| <dd>@javax.persistence.ForeignKey(javax.persistence.ConstraintMode.PROVIDER_DEFAULT)</dd> |
| </dl> |
| </li> |
| </ul> |
| </li> |
| </ul> |
| <ul class="blockList"> |
| <li class="blockList"><a name="joinTable--"> |
| <!-- --> |
| </a> |
| <ul class="blockListLast"> |
| <li class="blockList"> |
| <h4>joinTable</h4> |
| <pre>public abstract <a href="../../javax/persistence/JoinTable.html" title="annotation in javax.persistence">JoinTable</a> joinTable</pre> |
| <div class="block">The join table that maps the relationship. |
| The <code>joinTable</code> element must be specified if a join table |
| is used in the overriding of the mapping of the |
| relationship. The <code>joinTable</code> element must not be specified |
| if a foreign key mapping is used in the overriding of |
| the relationship.</div> |
| <dl> |
| <dt><span class="simpleTagLabel">Since:</span></dt> |
| <dd>Java Persistence 2.0</dd> |
| </dl> |
| <dl> |
| <dt>Default:</dt> |
| <dd>@javax.persistence.JoinTable</dd> |
| </dl> |
| </li> |
| </ul> |
| </li> |
| </ul> |
| </li> |
| </ul> |
| </div> |
| </div> |
| <!-- ========= END OF CLASS DATA ========= --> |
| <!-- ======= START OF BOTTOM NAVBAR ====== --> |
| <div class="bottomNav"><a name="navbar.bottom"> |
| <!-- --> |
| </a> |
| <div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div> |
| <a name="navbar.bottom.firstrow"> |
| <!-- --> |
| </a> |
| <ul class="navList" title="Navigation"> |
| <li><a href="../../overview-summary.html">Overview</a></li> |
| <li><a href="package-summary.html">Package</a></li> |
| <li class="navBarCell1Rev">Class</li> |
| <li><a href="package-tree.html">Tree</a></li> |
| <li><a href="../../deprecated-list.html">Deprecated</a></li> |
| <li><a href="../../index-all.html">Index</a></li> |
| <li><a href="../../help-doc.html">Help</a></li> |
| </ul> |
| </div> |
| <div class="subNav"> |
| <ul class="navList"> |
| <li><a href="../../javax/persistence/AccessType.html" title="enum in javax.persistence"><span class="typeNameLink">Prev Class</span></a></li> |
| <li><a href="../../javax/persistence/AssociationOverrides.html" title="annotation in javax.persistence"><span class="typeNameLink">Next Class</span></a></li> |
| </ul> |
| <ul class="navList"> |
| <li><a href="../../index.html?javax/persistence/AssociationOverride.html" target="_top">Frames</a></li> |
| <li><a href="AssociationOverride.html" target="_top">No Frames</a></li> |
| </ul> |
| <ul class="navList" id="allclasses_navbar_bottom"> |
| <li><a href="../../allclasses-noframe.html">All Classes</a></li> |
| </ul> |
| <div> |
| <script type="text/javascript"><!-- |
| allClassesLink = document.getElementById("allclasses_navbar_bottom"); |
| if(window==top) { |
| allClassesLink.style.display = "block"; |
| } |
| else { |
| allClassesLink.style.display = "none"; |
| } |
| //--> |
| </script> |
| </div> |
| <div> |
| <ul class="subNavList"> |
| <li>Summary: </li> |
| <li>Field | </li> |
| <li><a href="#annotation.type.required.element.summary">Required</a> | </li> |
| <li><a href="#annotation.type.optional.element.summary">Optional</a></li> |
| </ul> |
| <ul class="subNavList"> |
| <li>Detail: </li> |
| <li>Field | </li> |
| <li><a href="#annotation.type.element.detail">Element</a></li> |
| </ul> |
| </div> |
| <a name="skip.navbar.bottom"> |
| <!-- --> |
| </a></div> |
| <!-- ======== END OF BOTTOM NAVBAR ======= --> |
| </body> |
| </html> |