Sophie

Sophie

distrib > Mandriva > 2010.1 > x86_64 > media > main-release > by-pkgid > bc1980b66a68f286299491ee8724e71c > files > 440

db4.7-4.7.25-6mdv2010.1.x86_64.rpm

<!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_0) on Wed Dec 30 04:50:33 EST 2009 -->
<TITLE>
PrimaryKey
</TITLE>

<META NAME="date" CONTENT="2009-12-30">

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

<SCRIPT type="text/javascript">
function windowTitle()
{
    if (location.href.indexOf('is-external=true') == -1) {
        parent.document.title="PrimaryKey";
    }
}
</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="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>
</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">@Documented
@Retention(value=RUNTIME)
@Target(value=FIELD)
</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>A composite key class containing one or more simple type fields.</li>
 </ul>
 <p>Enum types and array types are not allowed.</p>

 <p>When using a composite key class containing more than one key field, 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 <CODE>Comparable.compareTo(T)</CODE> 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>To override the default sort order, you can use a composite key class
 that implements <CODE>Comparable</CODE>.  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;
     ...
 }
 @Entity
 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;java.lang.String</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 java.lang.String <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 that has 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="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>
</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>

</BODY>
</HTML>