File: PrimaryKey.html

package info (click to toggle)
db5.3 5.3.28%2Bdfsg2-10
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 158,624 kB
  • sloc: ansic: 448,573; java: 111,824; tcl: 80,544; sh: 44,264; cs: 33,697; cpp: 21,600; perl: 14,557; xml: 10,799; makefile: 4,029; javascript: 1,998; yacc: 1,003; awk: 965; sql: 801; erlang: 342; python: 216; php: 24; asm: 14
file content (351 lines) | stat: -rw-r--r-- 17,137 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--NewPage-->
<HTML>
<HEAD>
<!-- Generated by javadoc (build 1.6.0_51) on Mon Sep 09 11:47:06 EDT 2013 -->
<TITLE>
PrimaryKey (Oracle - Berkeley DB Java API)
</TITLE>

<META NAME="date" CONTENT="2013-09-09">

<LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../style.css" TITLE="Style">

<SCRIPT type="text/javascript">
function windowTitle()
{
    if (location.href.indexOf('is-external=true') == -1) {
        parent.document.title="PrimaryKey (Oracle - Berkeley DB Java API)";
    }
}
</SCRIPT>
<NOSCRIPT>
</NOSCRIPT>

</HEAD>

<BODY BGCOLOR="white" onload="windowTitle();">
<HR>


<!-- ========= START OF TOP NAVBAR ======= -->
<A NAME="navbar_top"><!-- --></A>
<A HREF="#skip-navbar_top" title="Skip navigation links"></A>
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
<TR>
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_top_firstrow"><!-- --></A>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
  <TR ALIGN="center" VALIGN="top">
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="class-use/PrimaryKey.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
  </TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
<b>Berkeley DB</b><br><font size="-1"> version 5.3.28</font></EM>
</TD>
</TR>

<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
&nbsp;<A HREF="../../../../com/sleepycat/persist/model/PersistentProxy.html" title="interface in com.sleepycat.persist.model"><B>PREV CLASS</B></A>&nbsp;
&nbsp;<A HREF="../../../../com/sleepycat/persist/model/PrimaryKeyMetadata.html" title="class in com.sleepycat.persist.model"><B>NEXT CLASS</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
  <A HREF="../../../../index.html?com/sleepycat/persist/model/PrimaryKey.html" target="_top"><B>FRAMES</B></A>  &nbsp;
&nbsp;<A HREF="PrimaryKey.html" target="_top"><B>NO FRAMES</B></A>  &nbsp;
&nbsp;<SCRIPT type="text/javascript">
  <!--
  if(window==top) {
    document.writeln('<A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>');
  }
  //-->
</SCRIPT>
<NOSCRIPT>
  <A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>
</NOSCRIPT>


</FONT></TD>
</TR>
<TR>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
  SUMMARY:&nbsp;REQUIRED&nbsp;|&nbsp;<A HREF="#annotation_type_optional_element_summary">OPTIONAL</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL:&nbsp;<A HREF="#annotation_type_element_detail">ELEMENT</A></FONT></TD>
</TR>
</TABLE>
<A NAME="skip-navbar_top"></A>
<!-- ========= END OF TOP NAVBAR ========= -->

<HR>
<!-- ======== START OF CLASS DATA ======== -->
<H2>
<FONT SIZE="-1">
com.sleepycat.persist.model</FONT>
<BR>
Annotation Type PrimaryKey</H2>
<HR>
<DL>
<DT><PRE><FONT SIZE="-1"><A HREF="http://download.oracle.com/javase/1.5.0/docs/api/java/lang/annotation/Documented.html?is-external=true" title="class or interface in java.lang.annotation">@Documented</A>
<A HREF="http://download.oracle.com/javase/1.5.0/docs/api/java/lang/annotation/Retention.html?is-external=true" title="class or interface in java.lang.annotation">@Retention</A>(<A HREF="http://download.oracle.com/javase/1.5.0/docs/api/java/lang/annotation/Retention.html?is-external=true#value()" title="class or interface in java.lang.annotation">value</A>=<A HREF="http://download.oracle.com/javase/1.5.0/docs/api/java/lang/annotation/RetentionPolicy.html?is-external=true#RUNTIME" title="class or interface in java.lang.annotation">RUNTIME</A>)
<A HREF="http://download.oracle.com/javase/1.5.0/docs/api/java/lang/annotation/Target.html?is-external=true" title="class or interface in java.lang.annotation">@Target</A>(<A HREF="http://download.oracle.com/javase/1.5.0/docs/api/java/lang/annotation/Target.html?is-external=true#value()" title="class or interface in java.lang.annotation">value</A>=<A HREF="http://download.oracle.com/javase/1.5.0/docs/api/java/lang/annotation/ElementType.html?is-external=true#FIELD" title="class or interface in java.lang.annotation">FIELD</A>)
</FONT>public @interface <B>PrimaryKey</B></DL>
</PRE>

<P>
Indicates the primary key field of an entity class.  The value of the
 primary key field is the unique identifier for the entity in a <A HREF="../../../../com/sleepycat/persist/PrimaryIndex.html" title="class in com.sleepycat.persist"><CODE>PrimaryIndex</CODE></A>.

 <p><A HREF="../../../../com/sleepycat/persist/model/PrimaryKey.html" title="annotation in com.sleepycat.persist.model"><CODE>PrimaryKey</CODE></A> may appear on at most one declared field per
 class.</p>

 <p>Primary key values may be automatically assigned as sequential integers
 using a <A HREF="../../../../com/sleepycat/persist/model/PrimaryKey.html#sequence()"><CODE>sequence()</CODE></A>.  In this case the type of the key field is
 restricted to a simple integer type.</p>

 <p>A primary key field may not be null, unless it is being assigned from a
 sequence.</p>

 <p><a name="keyTypes"><strong>Key Field Types</strong></a></p>

 <p>The type of a key field must either be one of the following:</p>
 <ul>
 <li>Any of the <a href="Entity.html#simpleTypes">simple
 types</a>.</li>
 <li>An enum type.</p>
 <li>A composite key class containing one or more simple type or enum
 fields.</li>
 </ul>
 <p>Array types are not allowed.</p>

 <p>When using a composite key class, each field of the composite key class
 must be annotated with <A HREF="../../../../com/sleepycat/persist/model/KeyField.html" title="annotation in com.sleepycat.persist.model"><CODE>KeyField</CODE></A> to identify the storage order and
 default sort order.  See <A HREF="../../../../com/sleepycat/persist/model/KeyField.html" title="annotation in com.sleepycat.persist.model"><CODE>KeyField</CODE></A> for an example and more
 information on composite keys.</p>

 <p><a name="sortOrder"><strong>Key Sort Order</strong></a></p>

 <p>Key field types, being simple types, have a well defined and reasonable
 default sort order, described below.  This sort order is based on a storage
 encoding that allows a fast byte-by-byte comparison.</p>
 <ul>
 <li>All simple types except for <code>String</code> are encoded so that they are
 sorted as expected, that is, as if the <A HREF="http://download.oracle.com/javase/1.5.0/docs/api/java/lang/Comparable.html?is-external=true#compareTo(T)" title="class or interface in java.lang"><CODE>Comparable.compareTo(T)</CODE></A> method
 of their class (or, for primitives, their wrapper class) is called.</li>
 <br>
 <li>Strings are encoded as UTF-8 byte arrays.  Zero (0x0000) character
 values are UTF encoded as non-zero values, and therefore embedded zeros in
 the string are supported.  The sequence {0xC0,0x80} is used to
 encode a zero character.  This UTF encoding is the same one used by native
 Java UTF libraries.  However, this encoding of zero does impact the
 lexicographical ordering, and zeros will not be sorted first (the natural
 order) or last.  For all character values other than zero, the default UTF
 byte ordering is the same as the Unicode lexicographical character
 ordering.</li>
 </ul>

 <p>When using a composite key class with more than one field, the sorting
 order among fields is determined by the <A HREF="../../../../com/sleepycat/persist/model/KeyField.html" title="annotation in com.sleepycat.persist.model"><CODE>KeyField</CODE></A> annotations.  To
 override the default sort order, you can use a composite key class that
 implements <A HREF="http://download.oracle.com/javase/1.5.0/docs/api/java/lang/Comparable.html?is-external=true" title="class or interface in java.lang"><CODE>Comparable</CODE></A>.  This allows overriding the sort order and is
 therefore useful even when there is only one key field in the composite key
 class.  See <a href="KeyField.html#comparable">Custom Sort Order</a>
 for more information on sorting of composite keys.</p>

 <p><a name="inherit"><strong>Inherited Primary Key</strong></a></p>

 <p>If it does not appear on a declared field in the entity class, <code>PrimaryKey</code> must appear on a field of an entity superclass.  In the
 following example, the primary key on the base class is used:</p>

 <pre class="code">
 @Persistent
 class BaseClass {
     @PrimaryKey
     long id;
     ...
 }
 @Entity
 class Employee extends BaseClass {
     // inherits id primary key
     ...
 }</pre>

 <p>If more than one class with <code>PrimaryKey</code> is present in a class
 hierarchy, the key in the most derived class is used.  In this case, primary
 key fields in superclasses are "shadowed" and are not persistent.  In the
 following example, the primary key in the base class is not used and is not
 persistent:</p>
 <pre class="code">
 @Persistent
 class BaseClass {
     @PrimaryKey
     long id;
     ...
 }
 @Entity
 class Employee extends BaseClass {
     // overrides id primary key
     @PrimaryKey
     String uuid;
     ...
 }</pre>

 <p>Note that a <code>PrimaryKey</code> is not allowed on entity subclasses.  The
 following is illegal and will cause an <code>IllegalArgumentException</code> when
 trying to store an <code>Employee</code> instance:</p>
 <pre class="code">
 @Entity
 class Person {
     @PrimaryKey
     long id;
     ...
 }
 @Persistent
 class Employee extends Person {
     @PrimaryKey
     String uuid;
     ...
 }</pre>
<P>

<P>
<HR>

<P>
<!-- =========== ANNOTATION TYPE OPTIONAL MEMBER SUMMARY =========== -->

<A NAME="annotation_type_optional_element_summary"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
<B>Optional Element Summary</B></FONT></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;<A HREF="http://download.oracle.com/javase/1.5.0/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../com/sleepycat/persist/model/PrimaryKey.html#sequence()">sequence</A></B></CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The name of a sequence from which to assign primary key values
 automatically.</TD>
</TR>
</TABLE>
&nbsp;
<P>
<A NAME="sequence()"><!-- --></A><H3>
sequence</H3>
<PRE>
public abstract <A HREF="http://download.oracle.com/javase/1.5.0/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</A> <B>sequence</B></PRE>
<DL>
<DD>The name of a sequence from which to assign primary key values
 automatically.  If a non-empty string is specified, sequential integers
 will be assigned from the named sequence.

 <p>A single sequence may be used for more than one entity class by
 specifying the same sequence name for each <code>PrimaryKey</code>.  For
 each named sequence, a <A HREF="../../../../com/sleepycat/db/Sequence.html" title="class in com.sleepycat.db"><CODE>Sequence</CODE></A> will be used to
 assign key values.  For more information on configuring sequences, see
 <A HREF="../../../../com/sleepycat/persist/EntityStore.html#setSequenceConfig(java.lang.String, com.sleepycat.db.SequenceConfig)"><CODE>EntityStore.setSequenceConfig</CODE></A>.</p>

 <p>To use a sequence, the type of the key field must be a primitive
 integer type (<code>byte</code>, <code>short</code>, <code>int</code> or <code>long</code>)
 or the primitive wrapper class for one of these types.  A composite key
 class may also be used to override sort order, but it may contain only a
 single key field, and this field must have one of the types previously
 mentioned.</p>

 <p>When an entity with a primary key sequence is stored using one of the
 <code>put</code> methods in the <A HREF="../../../../com/sleepycat/persist/PrimaryIndex.html" title="class in com.sleepycat.persist"><CODE>PrimaryIndex</CODE></A>, a new key will be
 assigned if the primary key field in the entity instance is null (for a
 reference type) or zero (for a primitive integer type).  Specifying zero
 for a primitive integer key field is allowed because the initial value
 of the sequence is one (not zero) by default.  If the sequence
 configuration is changed such that zero is part of the sequence, then
 the field type must be a primitive wrapper class and the field value
 must be null to cause a new key to be assigned.</p>

 <p>When one of the <code>put</code> methods in the <A HREF="../../../../com/sleepycat/persist/PrimaryIndex.html" title="class in com.sleepycat.persist"><CODE>PrimaryIndex</CODE></A>
 is called and a new key is assigned, the assigned value is returned to
 the caller via the key field of the entity object that is passed as a
 parameter.</p>
<P>
<DD><DL>
</DL>
</DD>
<DD><DL>
</DL>
<DL>
<DT><B>Default:</B><DD>""</DD>
</DL>
</DL>
<!-- ========= END OF CLASS DATA ========= -->
<HR>


<!-- ======= START OF BOTTOM NAVBAR ====== -->
<A NAME="navbar_bottom"><!-- --></A>
<A HREF="#skip-navbar_bottom" title="Skip navigation links"></A>
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
<TR>
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_bottom_firstrow"><!-- --></A>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
  <TR ALIGN="center" VALIGN="top">
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="class-use/PrimaryKey.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
  </TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
<b>Berkeley DB</b><br><font size="-1"> version 5.3.28</font></EM>
</TD>
</TR>

<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
&nbsp;<A HREF="../../../../com/sleepycat/persist/model/PersistentProxy.html" title="interface in com.sleepycat.persist.model"><B>PREV CLASS</B></A>&nbsp;
&nbsp;<A HREF="../../../../com/sleepycat/persist/model/PrimaryKeyMetadata.html" title="class in com.sleepycat.persist.model"><B>NEXT CLASS</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
  <A HREF="../../../../index.html?com/sleepycat/persist/model/PrimaryKey.html" target="_top"><B>FRAMES</B></A>  &nbsp;
&nbsp;<A HREF="PrimaryKey.html" target="_top"><B>NO FRAMES</B></A>  &nbsp;
&nbsp;<SCRIPT type="text/javascript">
  <!--
  if(window==top) {
    document.writeln('<A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>');
  }
  //-->
</SCRIPT>
<NOSCRIPT>
  <A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>
</NOSCRIPT>


</FONT></TD>
</TR>
<TR>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
  SUMMARY:&nbsp;REQUIRED&nbsp;|&nbsp;<A HREF="#annotation_type_optional_element_summary">OPTIONAL</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL:&nbsp;<A HREF="#annotation_type_element_detail">ELEMENT</A></FONT></TD>
</TR>
</TABLE>
<A NAME="skip-navbar_bottom"></A>
<!-- ======== END OF BOTTOM NAVBAR ======= -->

<HR>
<font size=1>Copyright (c) 1996, 2013 Oracle and/or its affiliates.  All rights reserved.</font>
</BODY>
</HTML>