blob: 271e20570b6a71fa624320526709ae0e4659a061 [file] [log] [blame]
<!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="../../jakarta/persistence/AccessType.html" title="enum in jakarta.persistence"><span class="typeNameLink">Prev&nbsp;Class</span></a></li>
<li><a href="../../jakarta/persistence/AssociationOverrides.html" title="annotation in jakarta.persistence"><span class="typeNameLink">Next&nbsp;Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../index.html?jakarta/persistence/AssociationOverride.html" target="_top">Frames</a></li>
<li><a href="AssociationOverride.html" target="_top">No&nbsp;Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_top">
<li><a href="../../allclasses-noframe.html">All&nbsp;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:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#annotation.type.required.element.summary">Required</a>&nbsp;|&nbsp;</li>
<li><a href="#annotation.type.optional.element.summary">Optional</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</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">jakarta.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="../../jakarta/persistence/AssociationOverrides.html" title="annotation in jakarta.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
&#064;MappedSuperclass
public class Employee {
...
&#064;ManyToOne
protected Address address;
...
}
&#064;Entity
&#064;AssociationOverride(name="address",
joinColumns=&#064;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
&#064;Entity
public class Employee {
&#064;Id int id;
&#064;AssociationOverride(
name="phoneNumbers",
joinTable=&#064;JoinTable(
name="EMPPHONES",
joinColumns=&#064;JoinColumn(name="EMP"),
inverseJoinColumns=&#064;JoinColumn(name="PHONE")
)
)
&#064;Embedded ContactInfo contactInfo;
...
}
&#064;Embeddable
public class ContactInfo {
&#064;ManyToOne Address address; // Unidirectional
&#064;ManyToMany(targetEntity=PhoneNumber.class) List phoneNumbers;
}
&#064;Entity
public class PhoneNumber {
&#064;Id int number;
&#064;ManyToMany(mappedBy="contactInfo.phoneNumbers")
Collection&#060;Employee&#062; employees;
}
</pre></div>
<dl>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>1.0</dd>
<dt><span class="seeLabel">See Also:</span></dt>
<dd><a href="../../jakarta/persistence/Embedded.html" title="annotation in jakarta.persistence"><code>Embedded</code></a>,
<a href="../../jakarta/persistence/Embeddable.html" title="annotation in jakarta.persistence"><code>Embeddable</code></a>,
<a href="../../jakarta/persistence/MappedSuperclass.html" title="annotation in jakarta.persistence"><code>MappedSuperclass</code></a>,
<a href="../../jakarta/persistence/AttributeOverride.html" title="annotation in jakarta.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">&nbsp;</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="../../jakarta/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">&nbsp;</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="../../jakarta/persistence/ForeignKey.html" title="annotation in jakarta.persistence">ForeignKey</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../jakarta/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="../../jakarta/persistence/JoinColumn.html" title="annotation in jakarta.persistence">JoinColumn</a>[]</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../jakarta/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="../../jakarta/persistence/JoinTable.html" title="annotation in jakarta.persistence">JoinTable</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../jakarta/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&nbsp;java.lang.String&nbsp;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&nbsp;<a href="../../jakarta/persistence/JoinColumn.html" title="annotation in jakarta.persistence">JoinColumn</a>[]&nbsp;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&nbsp;<a href="../../jakarta/persistence/ForeignKey.html" title="annotation in jakarta.persistence">ForeignKey</a>&nbsp;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>2.1</dd>
</dl>
<dl>
<dt>Default:</dt>
<dd>@jakarta.persistence.ForeignKey(jakarta.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&nbsp;<a href="../../jakarta/persistence/JoinTable.html" title="annotation in jakarta.persistence">JoinTable</a>&nbsp;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>2.0</dd>
</dl>
<dl>
<dt>Default:</dt>
<dd>@jakarta.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="../../jakarta/persistence/AccessType.html" title="enum in jakarta.persistence"><span class="typeNameLink">Prev&nbsp;Class</span></a></li>
<li><a href="../../jakarta/persistence/AssociationOverrides.html" title="annotation in jakarta.persistence"><span class="typeNameLink">Next&nbsp;Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../index.html?jakarta/persistence/AssociationOverride.html" target="_top">Frames</a></li>
<li><a href="AssociationOverride.html" target="_top">No&nbsp;Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="../../allclasses-noframe.html">All&nbsp;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:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#annotation.type.required.element.summary">Required</a>&nbsp;|&nbsp;</li>
<li><a href="#annotation.type.optional.element.summary">Optional</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</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>