blob: 34cb243ac265e437235a4a420f123f4fcc7611d4 [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>CollectionTable</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="CollectionTable";
}
}
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/CascadeType.html" title="enum in jakarta.persistence"><span class="typeNameLink">Prev&nbsp;Class</span></a></li>
<li><a href="../../jakarta/persistence/Column.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/CollectionTable.html" target="_top">Frames</a></li>
<li><a href="CollectionTable.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>Required&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 CollectionTable" class="title">Annotation Type CollectionTable</h2>
</div>
<div class="contentContainer">
<div class="description">
<ul class="blockList">
<li class="blockList">
<hr>
<br>
<pre>@Target(value={METHOD,FIELD})
@Retention(value=RUNTIME)
public @interface <span class="memberNameLabel">CollectionTable</span></pre>
<div class="block">Specifies the table that is used for the mapping of
collections of basic or embeddable types. Applied
to the collection-valued field or property.
<p>By default, the columns of the collection table that correspond
to the embeddable class or basic type are derived from the
attributes of the embeddable class or from the basic type according
to the default values of the <code>Column</code> annotation. In the case
of a basic type, the column name is derived from the name of the
collection-valued field or property. In the case of an embeddable
class, the column names are derived from the field or property
names of the embeddable class.
<ul>
<li> To override the default properties of the column used for a
basic type, the <code>Column</code> annotation is used on the
collection-valued attribute in addition to the
<code>ElementCollection</code> annotation.
<li> To override these defaults for an embeddable class, the
<code>AttributeOverride</code> and/or
<code>AttributeOverrides</code> annotations can be used in
addition to the <code>ElementCollection</code> annotation. If the
embeddable class contains references to other entities, the default
values for the columns corresponding to those references may be
overridden by means of the <code>AssociationOverride</code> and/or
<code>AssociationOverrides</code> annotations.
</ul>
<p> If the <code>CollectionTable</code> annotation is missing, the
default values of the <code>CollectionTable</code> annotation
elements apply.
<pre>
Example:
&#064;Embeddable public class Address {
protected String street;
protected String city;
protected String state;
...
}
&#064;Entity public class Person {
&#064;Id protected String ssn;
protected String name;
protected Address home;
...
&#064;ElementCollection // use default table (PERSON_NICKNAMES)
&#064;Column(name="name", length=50)
protected Set&#060;String&#062; nickNames = new HashSet();
...
}
&#064;Entity public class WealthyPerson extends Person {
&#064;ElementCollection
&#064;CollectionTable(name="HOMES") // use default join column name
&#064;AttributeOverrides({
&#064;AttributeOverride(name="street",
column=&#064;Column(name="HOME_STREET")),
&#064;AttributeOverride(name="city",
column=&#064;Column(name="HOME_CITY")),
&#064;AttributeOverride(name="state",
column=&#064;Column(name="HOME_STATE"))
})
protected Set&#060;Address&#062; vacationHomes = new HashSet();
...
}
</pre></div>
<dl>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>2.0</dd>
<dt><span class="seeLabel">See Also:</span></dt>
<dd><a href="../../jakarta/persistence/ElementCollection.html" title="annotation in jakarta.persistence"><code>ElementCollection</code></a>,
<a href="../../jakarta/persistence/AttributeOverride.html" title="annotation in jakarta.persistence"><code>AttributeOverride</code></a>,
<a href="../../jakarta/persistence/AssociationOverride.html" title="annotation in jakarta.persistence"><code>AssociationOverride</code></a>,
<a href="../../jakarta/persistence/Column.html" title="annotation in jakarta.persistence"><code>Column</code></a></dd>
</dl>
</li>
</ul>
</div>
<div class="summary">
<ul class="blockList">
<li class="blockList">
<!-- =========== 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>java.lang.String</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../jakarta/persistence/CollectionTable.html#catalog--">catalog</a></span></code>
<div class="block">(Optional) The catalog of the table.</div>
</td>
</tr>
<tr class="rowColor">
<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/CollectionTable.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="altColor">
<td class="colFirst"><code><a href="../../jakarta/persistence/Index.html" title="annotation in jakarta.persistence">Index</a>[]</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../jakarta/persistence/CollectionTable.html#indexes--">indexes</a></span></code>
<div class="block">(Optional) Indexes for the table.</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/CollectionTable.html#joinColumns--">joinColumns</a></span></code>
<div class="block">(Optional) The foreign key columns of the collection table
which reference the primary table of the entity.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>java.lang.String</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../jakarta/persistence/CollectionTable.html#name--">name</a></span></code>
<div class="block">(Optional) The name of the collection table.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>java.lang.String</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../jakarta/persistence/CollectionTable.html#schema--">schema</a></span></code>
<div class="block">(Optional) The schema of the table.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code><a href="../../jakarta/persistence/UniqueConstraint.html" title="annotation in jakarta.persistence">UniqueConstraint</a>[]</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../jakarta/persistence/CollectionTable.html#uniqueConstraints--">uniqueConstraints</a></span></code>
<div class="block">(Optional) Unique constraints that are to be placed on the
table.</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="blockList">
<li class="blockList">
<h4>name</h4>
<pre>public abstract&nbsp;java.lang.String&nbsp;name</pre>
<div class="block">(Optional) The name of the collection table. If not specified,
it defaults to the concatenation of the name of the containing
entity and the name of the collection attribute, separated by
an underscore.</div>
<dl>
<dt>Default:</dt>
<dd>""</dd>
</dl>
</li>
</ul>
</li>
</ul>
<ul class="blockList">
<li class="blockList"><a name="catalog--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>catalog</h4>
<pre>public abstract&nbsp;java.lang.String&nbsp;catalog</pre>
<div class="block">(Optional) The catalog of the table. If not specified, the
default catalog is used.</div>
<dl>
<dt>Default:</dt>
<dd>""</dd>
</dl>
</li>
</ul>
</li>
</ul>
<ul class="blockList">
<li class="blockList"><a name="schema--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>schema</h4>
<pre>public abstract&nbsp;java.lang.String&nbsp;schema</pre>
<div class="block">(Optional) The schema of the table. If not specified, the
default schema for the user is used.</div>
<dl>
<dt>Default:</dt>
<dd>""</dd>
</dl>
</li>
</ul>
</li>
</ul>
<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">(Optional) The foreign key columns of the collection table
which reference the primary table of the entity. The default
only applies if a single join column is used. The default is
the same as for <code>JoinColumn</code> (i.e., the
concatenation of the following: the name of the entity; "_";
the name of the referenced primary key column.) However, if
there is more than one join column, a <code>JoinColumn</code>
annotation must be specified for each join column using the
<code>JoinColumns</code> annotation. In this case, both the
<code>name</code> and the <code>referencedColumnName</code>
elements must be specified in each such
<code>JoinColumn</code> annotation.</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="uniqueConstraints--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>uniqueConstraints</h4>
<pre>public abstract&nbsp;<a href="../../jakarta/persistence/UniqueConstraint.html" title="annotation in jakarta.persistence">UniqueConstraint</a>[]&nbsp;uniqueConstraints</pre>
<div class="block">(Optional) Unique constraints that are to be placed on the
table. These are only used if table generation is in effect.</div>
<dl>
<dt>Default:</dt>
<dd>{}</dd>
</dl>
</li>
</ul>
</li>
</ul>
<ul class="blockList">
<li class="blockList"><a name="indexes--">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>indexes</h4>
<pre>public abstract&nbsp;<a href="../../jakarta/persistence/Index.html" title="annotation in jakarta.persistence">Index</a>[]&nbsp;indexes</pre>
<div class="block">(Optional) Indexes for the table. These are only used if
table generation is in effect.</div>
<dl>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>2.1</dd>
</dl>
<dl>
<dt>Default:</dt>
<dd>{}</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/CascadeType.html" title="enum in jakarta.persistence"><span class="typeNameLink">Prev&nbsp;Class</span></a></li>
<li><a href="../../jakarta/persistence/Column.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/CollectionTable.html" target="_top">Frames</a></li>
<li><a href="CollectionTable.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>Required&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>