Sophie

Sophie

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

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>
Entity
</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="Entity";
    }
}
</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/DeleteAction.html" title="enum in com.sleepycat.persist.model"><B>PREV CLASS</B></A>&nbsp;
&nbsp;<A HREF="../../../../com/sleepycat/persist/model/EntityMetadata.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/Entity.html" target="_top"><B>FRAMES</B></A>  &nbsp;
&nbsp;<A HREF="Entity.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 Entity</H2>
<HR>
<DL>
<DT><PRE><FONT SIZE="-1">@Documented
@Retention(value=RUNTIME)
@Target(value=TYPE)
</FONT>public @interface <B>Entity</B></DL>
</PRE>

<P>
Indicates a persistent entity class.  For each entity class, a <A HREF="../../../../com/sleepycat/persist/PrimaryIndex.html" title="class in com.sleepycat.persist"><CODE>PrimaryIndex</CODE></A> can be used to store and access instances of that class.
 Optionally, one or more <A HREF="../../../../com/sleepycat/persist/SecondaryIndex.html" title="class in com.sleepycat.persist"><CODE>SecondaryIndex</CODE></A> objects may be used to access
 entity instances by secondary key.

 <p><strong>Entity Subclasses and Superclasses</strong></p>

 <p>An entity class may have any number of subclasses and superclasses;
 however, none of these may themselves be entity classes (annotated with
 <code>Entity</code>).</p>

 <p>Entity superclasses are used to share common definitions and instance
 data.  For example, fields in an entity superclass may be defined as primary
 or secondary keys.</p>

 <p>Entity subclasses are used to provide polymorphism within a single <code>PrimaryIndex</code>.  Instances of the entity class and its subclasses are stored
 in the same <code>PrimaryIndex</code>.  Fields in an entity subclass may be
 defined as secondary keys.</p>

 <p>For example, the following <code>BaseClass</code> defines the primary key for
 any number of entity classes, using a single sequence to assign primary key
 values.  The entity class <code>Pet</code> extends the base class, implicitly
 defining a primary index that will contain instances of it and its
 subclasses, including <code>Cat</code> which is defined below.  The primary key
 (<code>id</code>) and secondary key (<code>name</code>) can be used to retrieve any
 <code>Pet</code> instance.</p>
 <pre class="code">
  @Persistent
  class BaseClass {
      @PrimaryKey(sequence="ID")
      long id;
  }

  @Entity
  class Pet extends BaseClass {
      @SecondaryKey(relate=ONE_TO_ONE)
      String name;
      float height;
      float weight;
  }</pre>

 <p>The entity subclass <code>Cat</code> defines a secondary key (<code>finickyness</code>) that only applies to <code>Cat</code> instances.  Querying by this
 key will never retrieve a <code>Dog</code> instance, if such a subclass existed,
 because a <code>Dog</code> instance will never contain a <code>finickyness</code>
 key.</p>
 <pre class="code">
  @Persistent
  class Cat extends Pet {
      @SecondaryKey(relate=MANY_TO_ONE)
      int finickyness;
  }</pre>

 <p><strong>Persistent Fields and Types</strong></p>

 <p>All non-transient instance fields of an entity class, as well as its
 superclasses and subclasses, are persistent.  <code>static</code> and <code>transient</code> fields are not persistent.  The persistent fields of a class may
 be <code>private</code>, package-private (default access), <code>protected</code> or
 <code>public</code>.</p>

 <p>It is worthwhile to note the reasons that object persistence is defined
 in terms of fields rather than properties (getters and setters).  This
 allows business methods (getters and setters) to be defined independently of
 the persistent state of an object; for example, a setter method may perform
 validation that could not be performed if it were called during object
 deserialization.  Similarly, this allows public methods to evolve somewhat
 independently of the (typically non-public) persistent fields.</p>

 <p><a name="simpleTypes"><strong>Simple Types</strong></a></p>

 <p>Persistent types are divided into simple types, enum types, complex
 types, and array types.  Simple types and enum types are single valued,
 while array types may contain multiple elements and complex types may
 contain one or more named fields.</p>

 <p>Simple types include:</p>
 <ul>
 <li>Java primitive types: <code>boolean, char, byte, short, int, long,
 float, double</code></p>
 <li>The wrapper classes for Java primitive types</p>
 <!--
 <li><CODE>BigDecimal</CODE></p>
 -->
 <li><CODE>BigInteger</CODE></p>
 <li><CODE>String</CODE></p>
 <li><CODE>Date</CODE></p>
 </ul>

 <p>When null values are required (for optional key fields, for example),
 primitive wrapper classes must be used instead of primitive types.</p>

 <p>Simple types, enum types and array types do not require annotations to
 make them persistent.</p>

 <p><a name="proxyTypes"><strong>Complex and Proxy Types</strong></a></p>

 <p>Complex persistent classes must be annotated with <A HREF="../../../../com/sleepycat/persist/model/Entity.html" title="annotation in com.sleepycat.persist.model"><CODE>Entity</CODE></A> or
 <A HREF="../../../../com/sleepycat/persist/model/Persistent.html" title="annotation in com.sleepycat.persist.model"><CODE>Persistent</CODE></A>, or must be proxied by a persistent proxy class
 (described below).  This includes entity classes, subclasses and
 superclasses, and all other complex classes referenced via fields of these
 classes.</p>

 <p>All complex persistent classes must have a default constructor.  The
 default constructor may be <code>private</code>, package-private (default
 access), <code>protected</code>, or <code>public</code>.  Other constructors are
 allowed but are not used by the persistence mechanism.</p>

 <p>It is sometimes desirable to store instances of a type that is externally
 defined and cannot be annotated or does not have a default constructor; for
 example, a class defined in the Java standard libraries or a 3rd party
 library.  In this case, a <A HREF="../../../../com/sleepycat/persist/model/PersistentProxy.html" title="interface in com.sleepycat.persist.model"><CODE>PersistentProxy</CODE></A> class may be used to
 represent the stored values for the externally defined type.  The proxy
 class itself must be annotated with <A HREF="../../../../com/sleepycat/persist/model/Persistent.html" title="annotation in com.sleepycat.persist.model"><CODE>Persistent</CODE></A> like other persistent
 classes, and the <A HREF="../../../../com/sleepycat/persist/model/Persistent.html#proxyFor()"><CODE>Persistent.proxyFor()</CODE></A> property must be specified.</p>

 <p>For convenience, built-in proxy classes are included for several common
 classes (listed below) in the Java library.  If you wish, you may define
 your own <A HREF="../../../../com/sleepycat/persist/model/PersistentProxy.html" title="interface in com.sleepycat.persist.model"><CODE>PersistentProxy</CODE></A> to override these built-in proxies.</p>
 <ul>
 <li><CODE>HashSet</CODE></li>
 <li><CODE>TreeSet</CODE></li>
 <li><CODE>HashMap</CODE></li>
 <li><CODE>TreeMap</CODE></li>
 <li><CODE>ArrayList</CODE></li>
 <li><CODE>LinkedList</CODE></li>
 </ul>

 <p>Complex persistent types should in general be application-defined
 classes.  This gives the application control over the persistent state and
 its evolution over time.</p>

 <p><strong>Other Type Restrictions</strong></p>

 <p>Entity classes and subclasses may not be used in field declarations for
 persistent types.  Fields of entity classes and subclasses must be simple
 types or non-entity persistent types (annotated with <A HREF="../../../../com/sleepycat/persist/model/Persistent.html" title="annotation in com.sleepycat.persist.model"><CODE>Persistent</CODE></A> not
 with <A HREF="../../../../com/sleepycat/persist/model/Entity.html" title="annotation in com.sleepycat.persist.model"><CODE>Entity</CODE></A>).</p>

 <p>Entity classes, subclasses and superclasses may be <code>abstract</code> and
 may implement arbitrary interfaces.  Interfaces do not need to be annotated
 with <A HREF="../../../../com/sleepycat/persist/model/Persistent.html" title="annotation in com.sleepycat.persist.model"><CODE>Persistent</CODE></A> in order to be used in a persistent class, since
 interfaces do not contain instance fields.</p>

 <p>Persistent instances of static nested classes are allowed, but the nested
 class must be annotated with <A HREF="../../../../com/sleepycat/persist/model/Persistent.html" title="annotation in com.sleepycat.persist.model"><CODE>Persistent</CODE></A> or <A HREF="../../../../com/sleepycat/persist/model/Entity.html" title="annotation in com.sleepycat.persist.model"><CODE>Entity</CODE></A>.  Inner
 classes (non-static nested classes, including anonymous classes) are not
 currently allowed as persistent types.</p>

 <p>Arrays of simple and persistent complex types are allowed as fields of
 persistent types.  Arrays may be multidimensional.  However, an array may
 not be stored as a top level instance in a primary index.  Only instances of
 entity classes and subclasses may be top level instances in a primary
 index.</p>

 <p><strong>Embedded Objects</strong></p>

 <p>As stated above, the embedded (or member) non-transient non-static fields
 of an entity class are themselves persistent and are stored along with their
 parent entity object.  This allows embedded objects to be stored in an
 entity to an arbitrary depth.</p>

 <p>There is no arbitrary limit to the nesting depth of embedded objects
 within an entity; however, there is a practical limit.  When an entity is
 marshalled, each level of nesting is implemented internally via recursive
 method calls.  If the nesting depth is large enough, a <code>StackOverflowError</code> can occur.  In practice, this has been observed with a
 nesting depth of 12,000, using the default Java stack size.</p>

 <p>This restriction on the nesting depth of embedded objects does not apply
 to cyclic references, since these are handled specially as described
 below.</p>

 <p><strong>Object Graphs</strong></p>

 <p>When an entity instance is stored, the graph of objects referenced via
 its fields is stored and retrieved as a graph.  In other words, if a single
 instance is referenced by two or more fields when the entity is stored, the
 same will be true when the entity is retrieved.</p>

 <p>When a reference to a particular object is stored as a member field
 inside that object or one of its embedded objects, this is called a cyclic
 reference.  Because multiple references to a single object are stored as
 such, cycles are also represented correctly and do not cause infinite
 recursion or infinite processing loops.  If an entity containing a cyclic
 reference is stored, the cyclic reference will be present when the entity is
 retrieved.</p>

 <p>Note that the stored object graph is restricted in scope to a single
 entity instance.  This is because each entity instance is stored separately.
 If two entities have a reference to the same object when stored, they will
 refer to two separate instances when the entities are retrieved.</p>
<P>

<P>
<DL>
<DT><B>See Also:</B><DD><A HREF="../../../../com/sleepycat/persist/model/Persistent.html" title="annotation in com.sleepycat.persist.model"><CODE>Persistent</CODE></A>, 
<A HREF="../../../../com/sleepycat/persist/model/PrimaryKey.html" title="annotation in com.sleepycat.persist.model"><CODE>PrimaryKey</CODE></A>, 
<A HREF="../../../../com/sleepycat/persist/model/SecondaryKey.html" title="annotation in com.sleepycat.persist.model"><CODE>SecondaryKey</CODE></A>, 
<A HREF="../../../../com/sleepycat/persist/model/KeyField.html" title="annotation in com.sleepycat.persist.model"><CODE>KeyField</CODE></A></DL>
<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;int</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../com/sleepycat/persist/model/Entity.html#version()">version</A></B></CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Identifies a new version of a class when an incompatible class change
 has been made.</TD>
</TR>
</TABLE>
&nbsp;
<P>
<A NAME="version()"><!-- --></A><H3>
version</H3>
<PRE>
public abstract int <B>version</B></PRE>
<DL>
<DD>Identifies a new version of a class when an incompatible class change
 has been made.  Prior versions of a class are referred to by version
 number to perform class evolution and conversion using <A HREF="../../../../com/sleepycat/persist/evolve/Mutations.html" title="class in com.sleepycat.persist.evolve"><CODE>Mutations</CODE></A>.

 <p>The first version of a class is version zero, if <A HREF="../../../../com/sleepycat/persist/model/Entity.html#version()"><CODE>version()</CODE></A> is
 not specified.  When an incompatible class change is made, a version
 number must be assigned using <A HREF="../../../../com/sleepycat/persist/model/Entity.html#version()"><CODE>version()</CODE></A> that is higher than the
 previous version number for the class.  If this is not done, an <A HREF="../../../../com/sleepycat/persist/evolve/IncompatibleClassException.html" title="class in com.sleepycat.persist.evolve"><CODE>IncompatibleClassException</CODE></A> will be thrown when the store is opened.</p>
<P>
<DD><DL>
</DL>
</DD>
<DD><DL>
</DL>
<DL>
<DT><B>Default:</B><DD>0</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/DeleteAction.html" title="enum in com.sleepycat.persist.model"><B>PREV CLASS</B></A>&nbsp;
&nbsp;<A HREF="../../../../com/sleepycat/persist/model/EntityMetadata.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/Entity.html" target="_top"><B>FRAMES</B></A>  &nbsp;
&nbsp;<A HREF="Entity.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>