db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arm...@apache.org
Subject cvs commit: db-ojb/src/schema ojbcore-schema.xml
Date Tue, 01 Apr 2003 14:06:12 GMT
arminw      2003/04/01 06:06:12

  Modified:    xdocs    sequencemanager.xml repository.xml
               src/test/org/apache/ojb repository_internal.xml
                        repository_database.xml repository.dtd
               src/test/org/apache/ojb/faraway-db OJB_FarAway.script
               src/test/org/apache/ojb/broker Role.java ReferenceTest.java
                        MultipleDBTest.java FarAwayReference.java
                        FarAwayClass.java
               src/test/org/apache/ojb/broker/sequence SMSameTableB.java
                        SMSameTableA.java SMMax.java SMKey.java
                        SequenceManagerTest.java
               src/schema ojbcore-schema.xml
  Log:
  - update sequence package
  - sequence manager implementation
  now use long instead of int ids
  - SequenceManagerHighLowImpl now use optimistic
  locking
  - make some test classes serializable
  - update scripts/schema to support new OL field
  'VERSION' in OJB_HL_SEQ
  
  Revision  Changes    Path
  1.6       +262 -92   db-ojb/xdocs/sequencemanager.xml
  
  Index: sequencemanager.xml
  ===================================================================
  RCS file: /home/cvs/db-ojb/xdocs/sequencemanager.xml,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- sequencemanager.xml	15 Jan 2003 10:51:23 -0000	1.5
  +++ sequencemanager.xml	1 Apr 2003 14:06:11 -0000	1.6
  @@ -15,12 +15,24 @@
       <li><a href="#automatical">Automatical assignment of unique values</a></li>
       <li><a href="#force">Force computation of unique values</a></li>
       <li><a href="#howToChange">How to change the sequence manager?</a></li>
  -    <li><a href="#alternative">Alternative SequenceManagers</a></li>
  -    <li><a href="#whenUsing">When using sequence-name attribute in field-descriptor?</a></li>
  -    <li><a href="#sequenceManagerHandling">Sequence manager handling using multiple databases</a></li>
  -    <li><a href="#oneSequenceManager">One sequence manager with multiple databases?</a></li>
  -    <li><a href="#directAccess">Can I get direct access to the sequence manager?</a></li>
  +    <li><a href="#implementations">SequenceManager implementations</a>
  +        <ul>
  +            <li><a href="#High/Low sequence manager">High/Low sequence manager</a></li>
  +            <li><a href="#In-Memory sequence manager">In-Memory sequence manager</a></li>
  +            <li><a href="#Database sequences based implementation">Database sequences based implementation</a></li>
  +            <li><a href="#Database sequences based high/low implementation">Database sequences based high/low implementation</a></li>
  +            <li><a href="#Oracle-style sequencing">Oracle-style sequencing using stored procedure</a></li>
  +        </ul>
  +    </li>
       <li><a href="#howToWrite">How to write my own sequence manager?</a></li>
  +    <li><a href="#questions">Questions</a></li>
  +        <ul>
  +            <li><a href="#whenUsing">When using sequence-name attribute in field-descriptor?</a></li>
  +            <li><a href="#sequenceManagerHandling">Sequence manager handling using multiple databases</a></li>
  +            <li><a href="#oneSequenceManager">One sequence manager with multiple databases?</a></li>
  +            <li><a href="#directAccess">Can I get direct access to the sequence manager?</a></li>
  +            <li><a href="#pitfalls">Any known pitfalls?</a></li>
  +        </ul>
   </ul>
   All sequence manager implementations you will find under the
   <code>org.apache.ojb.broker.util.sequence</code>-package using the following naming
  @@ -33,25 +45,23 @@
   attribute in the respective FieldDescriptor of the XML
   repository file as follows:
   </p>
  -    <source>
  -    <![CDATA[
  -    <class-descriptor
  -   	  class="my.Article"
  -   	  table="ARTICLE"
  -    >
  -        <field-descriptor
  -         name="articleId"
  -         column="ARTICLE_ID"
  -         jdbc-type="INTEGER"
  -         primarykey="true"
  -         autoincrement="true"
  -        />
  -
  -        ....
  +<source>
  +<![CDATA[
  +<class-descriptor
  +  class="my.Article"
  +  table="ARTICLE"
  +>
  +    <field-descriptor
  +     name="articleId"
  +     column="ARTICLE_ID"
  +     jdbc-type="INTEGER"
  +     primarykey="true"
  +     autoincrement="true"
  +    />
  +    ....
   
  -    </class-descriptor>
  -      ]]>
  -    </source>
  +</class-descriptor>
  +]]></source>
   <p>
   This definitions contains the following information:<br/>
   The attribute
  @@ -91,13 +101,18 @@
   
   <subsection name="How to change the sequence manager?" anchor="howToChange">
   <p>
  -You could change the used sequence manager implementation by adding
  -a <code>sequence-manager</code> tag in the <code>jdbc-connection-descriptor</code>.
  -If no <code>sequence-manager</code> was specified in the descriptor,
  -OJB use a default sequence manager implementation.
  +To enable a specific <code>SequenceManager</code> implementation declare
  +an <code>sequence-manager</code> within the <code>jdbc-connection-descriptor</code>
  +element in the <a href="repository.html">repository file</a>.
  +If no <code>sequence-manager</code> was specified in the <code>jdbc-connection-descriptor</code>,
  +OJB use a default sequence manager implementation (default was <i>SequenceManagerHighLowImpl</i>).
   </p>
   <p>
  -Example descriptor using <code>sequence-manager</code> tag:
  +Further information you could find in the
  +<a href="repository.dtd.txt">repository.dtd</a> section sequence-manager element.
  +</p>
  +<p>
  +Example <code>jdbc-connection-descriptor</code> using <code>sequence-manager</code> tag:
   <source><![CDATA[
   <jdbc-connection-descriptor
           jcd-alias="farAway"
  @@ -118,8 +133,12 @@
           />
   
           <sequence-manager className="org.apache.ojb.broker.util.
  -                                      sequence.SequenceManagerHighLowImpl">
  +                                    sequence.SequenceManagerHighLowImpl">
               <attribute attribute-name="grabSize" attribute-value="5"/>
  +            <attribute attribute-name="globalSequenceId"
  +                    attribute-value="false"/>
  +            <attribute attribute-name="globalSequenceStart"
  +                    attribute-value="10000"/>
           </sequence-manager>
   </jdbc-connection-descriptor>
   ]]></source>
  @@ -130,75 +149,112 @@
   properties you pass them using <code>attribute</code> tags with
   <code>attribute-name</code> represents the property name and <code>attribute-value</code>
   the property value. Each sequence manager implementation shows all properties on
  -the according javadoc page. Further information you could find in the
  -<a href="repository.dtd.txt">repository.dtd</a>.
  +the according javadoc page.
   </p>
   </subsection>
   
   
   
   
  -<subsection name="Alternative SequenceManagers" anchor="alternative">
  +<subsection name="SequenceManager implementations" anchor="implementations">
  +<p>
  +Source code of all <code>SequenceManager</code> implementations could be
  +found in <code>org.apache.ojb.broker.util.sequence</code> package.
  +<br/>
  +If you still think something is missing you can just write your <a href="#howToWrite">own</a>
  +sequence manager implementation.
  +</p>
   
  +<br/>
   <p>
  +<a name="High/Low sequence manager"/>
   <b>High/Low sequence manager</b><br/>
   Per default OJB internally uses a High/Low algorithm based sequence manager
   for the generation of unique ids, as described in
   <a href="http://www.ambysoft.com/mappingObjects.html">
   Mapping Objects To Relational Databases</a>.
  -This implementation is called
  -<code>ojb.broker.util.sequence.SequenceManagerHighLowImpl</code>.
   <br/>
  -This implementation is able to generate IDs unique to a given object and
  +This implementation is called
  +<code>ojb.broker.util.sequence.SequenceManagerHighLowImpl</code>
  +and is able to generate IDs unique to a given object and
   all extent objects declarated in the objects class descriptor.
  +<br/>
   If you ask for an uid using an interface with several
   implementor classes, or a baseclass with several subclasses the returned
   uid have to be unique accross all tables representing objects of the
   extent in question.
  +<br/>
  +It's also possible to use this implementation in a <i>global mode</i>, generate
  +global unique id's.
   
   <source><![CDATA[
  -<sequence-manager className="org.apache.ojb.broker.util.
  -                                      sequence.SequenceManagerHighLowImpl">
  -   <attribute attribute-name="grabSize" attribute-value="20"/>
  -   <attribute attribute-name="globalSequenceId" attribute-value="false"/>
  +<sequence-manager className=
  +    "org.apache.ojb.broker.util.sequence.SequenceManagerHighLowImpl">
  +
  +    <attribute attribute-name="grabSize" attribute-value="20"/>
  +    <attribute attribute-name="globalSequenceId"
  +                                    attribute-value="false"/>
  +    <attribute attribute-name="globalSequenceStart"
  +                                    attribute-value="10000"/>
   </sequence-manager>
   ]]></source>
   
  -With the property <code>grabSize</code> you set the size of the assigned ids.
  +With the property <code>grabSize</code> you set the size of the assigned ids
  +(default was 20).
  +<br/>
   If property <code>globalSequenceId</code> was set <code>true</code> you will
  -get unique ids over all persistent objects (Normally you don't need this, anymore
  -this is not a extent-aware adjustment). Default was <code>false</code>.
  +get global unique ids over all persistent objects. Default was <code>false</code>.
  +<br/>
  +The attribute <code>globalSequenceStart</code> define the start value of the
  +global id generation (default was 10000).
   </p>
   <p>
  -This sequence manager implementation supports user defined sequence-names
  -to manage the high/low sequences - see <a href="#sequenceName">more</a>.
  +This sequence manager implementation supports user defined <i>sequence-names</i>
  +to manage the sequences (see <a href="#sequenceName">more</a>) or if not
  +set in <code>field-descriptor</code> it is done automatic.
  +</p>
  +<p>
  +Limitations:
  +<br/>- do not use when connections were associated with a
  +transaction, e.g. when using DataSources from an j2ee conform application server
  +<br/>- do not use if other entities use database based sequencing
   </p>
   
  -
  +<br/>
   <p>
  +<a name="In-Memory sequence manager"/>
   <b>In-Memory sequence manager</b><br/>
  -Another implementation is a In-Memory sequence manager
  -<code>ojb.broker.util.sequence.SequenceManagerInMemoryImpl</code>.
  -Only the first time an id was requested for a object,
  +Another sequence manager implementation is a <i>In-Memory</i> version
  +called <code>ojb.broker.util.sequence.SequenceManagerInMemoryImpl</code>.
  +<br/>
  +Only the first time an uid was requested for a object,
   the manager query the database for the max value of the target
   column - all following request were performed in memory. This
   implementation ditto generate unique ids across all
   extents, using the same mechanism as the High/Low implementation.
  -<br/>
  -This is the fastest standard sequence manager implementation, but
  -has some Limitations:
  -<br/>- do not use in client/server mode
  -<br/>- do not use in clustered environments
  -<br/>- do not use if other entities generate id's for the persistent objects
   <source><![CDATA[
   <sequence-manager className="org.apache.ojb.broker.util.
  -                                      sequence.SequenceManagerInMemoryImpl">
  +                                sequence.SequenceManagerInMemoryImpl">
   </sequence-manager>
   ]]></source>
  +
  +</p>
  +<p>
  +This sequence manager implementation supports user defined <i>sequence-names</i>
  +to manage the sequences (see <a href="#sequenceName">more</a>) or if not
  +set in <code>field-descriptor</code> it is done automatic.
  +</p>
  +<p>
  +This is the fastest standard sequence manager implementation, but
  +has some Limitations:
  +<br/>- do not use in clustered environments
  +<br/>- do not use if other entities use database based sequencing
   </p>
   
   
  +<br/>
   <p>
  +<a name="Database sequences based implementation"/>
   <b>Database sequences based implementation</b><br/>
   If your database support sequence key generation (e.g. Oracle, SAP DB, PostgreSQL)
   you could use the <code>SequenceManagerNextValImpl</code> implementation let
  @@ -212,11 +268,15 @@
   <a name="sequenceName"/>
   When using this sequence manager it is possible
   to define a <code>sequence-name</code> field-descriptor attribute
  -in the repository file for each autoincrement field.
  +in the repository file for each autoincrement field. If you don't
  +specify a sequence name, the sequence manager try to
  +build a extent-aware sequence name on its own.
   <br/>
   Keep in mind that in this case you are responsible to be aware of extents.
   Thus you have to use the same <code>sequence-name</code> attribute value
   for all extents, even if the extents were mapped to different database tables.
  +<br/>
  +See usage of the <code>sequence-name</code> attribute:
   <source><![CDATA[
   <class-descriptor
         class="org.apache.ojb.broker.sequence.SMDatabaseSequence"
  @@ -234,67 +294,106 @@
           ....
       </class-descriptor>
   ]]></source>
  -<br/>
  -When you don't specify a sequence name, the implementation try to
  -build a extent-aware sequence name on its own.
  +</p>
  +<p>
  +Limitations:
  +<br/>- none known
   </p>
   
  -
  +<br/>
   <p>
  +<a name="Database sequences based high/low implementation"/>
   <b>Database sequences based high/low implementation</b><br/>
   Based on the sequence manager implementation described above, but
   use a high/low algorithm to avoid database access.
   <source><![CDATA[
   <sequence-manager className="org.apache.ojb.broker.util.
  -                                      sequence.SequenceManagerSeqHiLoImpl">
  +                            sequence.SequenceManagerSeqHiLoImpl">
       <attribute attribute-name="grabSize" attribute-value="20"/>
   </sequence-manager>
   ]]></source>
   With the property
   <code>grabSize</code> you set the size of the assigned ids.
   </p>
  -
   <p>
  -If you still think something is missing you can just write your <a href="#howToWrite">own</a>
  -sequence manager implementation.
  +This sequence manager implementation supports user defined <i>sequence-names</i>
  +to manage the sequences (see <a href="#sequenceName">more</a>) or if not
  +set in <code>field-descriptor</code> it is done automatic.
   </p>
  -</subsection>
  -
  -
  -
  -
  -
  -<subsection name="When using sequence-name attribute in field-descriptor?" anchor="whenUsing">
   <p>
  -TODO
  +Limitations:
  +<br/>- do not use if other entities use database based sequencing
   </p>
  -</subsection>
  -
   
   
  -
  -<subsection name="Sequence manager handling using multiple databases" anchor="sequenceManagerHandling">
  +<br/>
   <p>
  -TODO
  +<a name="Oracle-style sequencing"/>
  +<b>Oracle-style sequencing using stored procedure</b><br/>
  +<font size="-1">(Thanks Ryan Vanderwerf et al.)</font>
  +<br/>
  +Ryan wrote:
  +<br/>
  +This solution will give those seeking an oracle-style sequence generator
  +a final answer (Identity columns really suck).
  +<br/>
  +The <code>SequenceManagerStoredProcedureImpl</code> implementation enabled database
  +sequence key generation in a <i>Oracle-style</i> for all databases (e.g. MSSQL, MySQL, DB2, ...).
  +<br/>
  +First add a new table <code>OJB_NEXTVAL</code> to
  +your database.
  +<source>
  +CREATE TABLE OJB_NEXTVAL
  +(
  +    SEQ_NAME    VARCHAR(150) NOT NULL,
  +    MAX_KEY     INTEGER,
  +    CONSTRAINT SYS_PK_OJB_NEXTVAL PRIMARY KEY(SEQ_NAME)
  +)
  +</source>
  +You will also need a stored procedure called <code>ojb_nextval</code>
  +that will take care of giving you a guaranteed unique
  +sequence number.
  +<br/>
  +Here is an example for the stored procedure you need to
  +use sequencing for MSSQL server:
  +<source>
  +CREATE PROCEDURE ojb_nextval
  +    @SEQ_NAME varchar(150)
  +    AS
  +    declare @MAX_KEY BIGINT
  +    -- return an error if sequence does not exist
  +    -- so we will know if someone truncates the table
  +    set @MAX_KEY = 0
  +
  +    UPDATE OJB_NEXTVAL
  +        SET    @MAX_KEY = MAX_KEY = MAX_KEY + 1
  +        WHERE  SEQ_NAME = @SEQ_NAME
  +
  +    if @MAX_KEY = 0
  +        select 1/0
  +    else
  +        select @MAX_KEY
  +RETURN @MAX_KEY
  +</source>
  +You have to adapt this script if MSSQL was not used
  +(We are interested in scripts for other databases).
  +Last, enable this sequence manager implementation:
  +<source><![CDATA[
  +<sequence-manager className="org.apache.ojb.broker.util.
  +                       sequence.SequenceManagerStoredProcedureImpl">
  +</sequence-manager>
  +]]></source>
   </p>
  -</subsection>
  -
  -
  -
  -
  -<subsection name="One sequence manager with multiple databases?" anchor="oneSequenceManager">
   <p>
  -TODO
  +This sequence manager implementation supports user defined <i>sequence-names</i>
  +to manage the sequences (see <a href="#sequenceName">more</a>) or if not
  +set in <code>field-descriptor</code> it is done automatic.
   </p>
  -</subsection>
  -
  -
  -
  -
  -<subsection name="Can I get direct access to the sequence manager?" anchor="directAccess">
   <p>
  -TODO
  +Limitations:
  +<br/>- currently none known
   </p>
  +
   </subsection>
   
   
  @@ -337,12 +436,83 @@
   
   <p>
   Of course I'm interested in your solutions! If you have
  -implemented something interesting, just contact me.
  +implemented something interesting, just contact us.
   </p>
   
   </subsection>
   
   
  +<subsection name="Questions" anchor="questions">
  +
  +<p>
  +<a name="whenUsing"/>
  +<br/><b>When using sequence-name attribute in field-descriptor?</b><br/>
  +Most <code>SequenceManager</code> implementations based on sequence names.
  +If you want retain control of sequencing use your own <code>sequence-name</code> attribute
  +in the <code>field-descriptor</code>. In that case you are reponsible to use the same name
  +across extents (extent <a href="tutorial3.html#extents and polymorphism">see more info</a>).
  +Per default the sequence manager build its own <i>extent aware</i> sequence name if necessary.
  +<br/>
  +In most cases
  +</p>
  +
  +
  +<p>
  +<a name="sequenceManagerHandling"/>
  +<br/><b>Sequence manager handling using multiple databases</b><br/>
  +If you use multiple databases you have to declare a sequence manager in each
  +<code>jdbc-connection-descriptor</code>.
  +</p>
  +
  +
  +<p>
  +<a name="oneSequenceManager"/>
  +<br/><b>One sequence manager with multiple databases?</b><br/>
  +OJB was intended to use a sequence manager per database. But it
  +shouldn't be complicated to realize a global sequence manager
  +solution by writing your own <code>SequenceManager</code> implementation.
  +</p>
  +
  +
  +<p>
  +<a name="directAccess"/>
  +<br/><b>Can I get direct access to the sequence manager?</b><br/>
  +That's no problem:
  +<source>
  +PersistenceBroker broker =
  +    PersistenceBrokerFactory.createPersistenceBroker(myPBKey);
  +SequenceManager sm = broker.serviceSequenceManager();
  +...
  +broker.close();
  +</source>
  +If you use <code>autoincrement=true</code> in your <code>field-descriptor</code>,
  +there is no reason to obtain UID directly from the sequence manager or to handle
  +UID in your object model.
  +</p>
  +
  +
  +<p>
  +<a name="pitfalls"/>
  +<br/><b>Any known pitfalls?</b><br/>
  +- When enable a sequence manager implementation based on <i>sequence-name</i> attributes
  +and if the name was not set as an attribute in the <code>field-descriptor</code>
  +(<a href="sequenceName">see</a>), an simple algorithm was used to build the sequence name.
  +<br/>
  +The algorithm try to get the top-level class of the field's enclosing class,
  +if no top-level class was found, the table name of the field's enclosing class was used.
  +If a top-level class was found, the first found extent class table name was used as sequence name.
  +<br/>
  +When using base classes/interfaces with extent classes based on different database tables
  +and the <code>extent-class</code> entries in repository often change, the algorithm could be
  +corrupted, because the first found extent class's table name could be change.
  +<br/>
  +To avoid this, remove the implementation internal sequence name entry (e.g. OJB_HL_SEQ table
  +entry when using the Hi/Lo implementation, or remove the database sequence entry when using
  +the 'Nextval' implementation) in that case, or use custom sequence name attributes in the
  +field descriptor.
  +</p>
  +
  +</subsection>
   </section>
   </body>
   </document>
  
  
  
  1.17      +25 -35    db-ojb/xdocs/repository.xml
  
  Index: repository.xml
  ===================================================================
  RCS file: /home/cvs/db-ojb/xdocs/repository.xml,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- repository.xml	30 Mar 2003 15:02:39 -0000	1.16
  +++ repository.xml	1 Apr 2003 14:06:11 -0000	1.17
  @@ -73,10 +73,10 @@
       touch the isolation-level off the database.
   <br/><br/>
   	The version attribute is used to bind a repository.xml file to a given
  -	version of this dtd. 
  +	version of this dtd.
   	A given OJB release will work properly only with the repository version
  -	shipped with that relase. 
  -	This strictness maybe inconvenient but it does help to avoid the 
  +	shipped with that relase.
  +	This strictness maybe inconvenient but it does help to avoid the
   	most common version conflicts.
   </p>
   <source><![CDATA[
  @@ -264,6 +264,17 @@
   idle object evictor thread (if any)
   </li>
   <li>
  +validationQuery<br/>
  +Here you could specify a validation query used by the ConnectionFactory
  +implementations using connection pooling,
  +to test a requested connection (e.g. "select 1 from dual") before
  +leave the pool (used by <code>ConnectionFactoryDBCPImpl</code>
  +and <code>ConnectionFactoryPooledImpl</code>).
  +<br/>
  +If not set, only <i>connection.isClosed()</i>
  +was called before connection was delivered.
  +</li>
  +<li>
   logAbandoned<br/>
   Only supported when using
   org.apache.ojb.broker.accesslayer.ConnectionFactoryDBCPImpl
  @@ -329,35 +340,14 @@
   ]]></source>
   
   <p>
  -    The className attribute represents the full qualified class name
  -    of the desired sequence manager implementation - it is mandatory
  -    when using the sequence-manager element.
  -    All sequence manager implementations you find will under
  -    org.apache.ojb.broker.util.sequence package named as SequenceManagerXXXImpl
  -<br/><br/>
  -    Sequence Manager implementations
  -<br/><br/>
  -    1. className="org.apache.ojb.broker.util.sequence.SequenceManagerHighLowImpl"
  -    High/Low sequence manager implementation. This is OJB's default sequence manager.
  -<br/><br/>
  -    2. className=org.apache.ojb.broker.util.sequence.SequenceManagerInMemoryImpl
  -    InMemory-sequence manager implementation.
  -    This is the fastest standard sequence manager implementation, but
  -    has some limitations:<br/>
  -    - do not use in client/server mode<br/>
  -    - do not use in clustered environments<br/>
  -    - do not use if other entities generate id's for the persistent objects
  -<br/><br/>
  -    3. className=org.apache.ojb.broker.util.sequence.SequenceManagerNextValImpl
  -    Use database based sequence generation. Check your DB for support, add
  -    a extent aware 'sequence-name' attribute to your autoincrement field
  -    descriptors. If no sequence-name was found by the implementation,
  -    an extent aware sequence name is build by it's own.
  -<br/><br/>
  -    4. className=org.apache.ojb.broker.util.sequence.SequenceManagerSeqNextValImpl
  -    A database sequence based High/Low implementation. See 3. for more informantion.
  -    Limitations:<br/>
  -    - do not use when other applications use the database sequence ditto
  +The className attribute represents the full qualified class name
  +of the desired sequence manager implementation - it is mandatory
  +when using the sequence-manager element.
  +All sequence manager implementations you find will under
  +org.apache.ojb.broker.util.sequence package named as SequenceManagerXXXImpl
  +</p>
  +<p>
  +More info about the usage of the <a href="sequencemanager.html">Sequence Manager</a> implementations
   </p>
   
   <source><![CDATA[
  @@ -422,7 +412,7 @@
   	The optional initialization-method specifies a no-argument instance
   	method that is invoked after reading an instnace from a database row.
   	It can be used to do initialization and validations.
  -<br/><br/>	
  +<br/><br/>
   	The optional factory-method specifies a static no-argument method
   	that is to be used instead of a no argument constructor.<br/>
   	Important note: this feature is not yet implemented.
  @@ -483,7 +473,7 @@
   	If a different sort order is intended the id attribute may be used to
   	hold a unique number identifying the decriptors position in the sequence of
   	field-descriptors.<br/>
  -	The order of the numbers for the field-descriptors must correspond to 
  +	The order of the numbers for the field-descriptors must correspond to
   	the order of columns in the mapped table.
   <br/><br/>
   	The name attribute holds the name of the persistent classes attribute.
  @@ -540,7 +530,7 @@
   	The access attribute specifies the accessibility of the field.
   	"readonly" marks fields that are not to modified. "readwrite" marks
   	fields that may be read and written to. "anonymous" marks anonymous fields.
  -	An anonymous field has a database representation (column) but no 
  +	An anonymous field has a database representation (column) but no
   	corresponding Java attribute. Hence the name of such a field does not
   	refer to a Java attribute of the class, but is used as a unique
   	identifier only.
  
  
  
  1.6       +33 -27    db-ojb/src/test/org/apache/ojb/repository_internal.xml
  
  Index: repository_internal.xml
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/repository_internal.xml,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- repository_internal.xml	2 Jan 2003 21:27:19 -0000	1.5
  +++ repository_internal.xml	1 Apr 2003 14:06:11 -0000	1.6
  @@ -5,28 +5,34 @@
      	  class="org.apache.ojb.broker.util.sequence.HighLowSequence"
      	  table="OJB_HL_SEQ"
      >
  -      <field-descriptor 
  +      <field-descriptor
            name="tableName"
            column="TABLENAME"
            jdbc-type="VARCHAR"
            primarykey="true"
         />
  -      <field-descriptor 
  +      <field-descriptor
            name="fieldName"
            column="FIELDNAME"
            jdbc-type="VARCHAR"
            primarykey="true"
         />
  -      <field-descriptor 
  +      <field-descriptor
            name="maxKey"
            column="MAX_KEY"
            jdbc-type="INTEGER"
         />
  -      <field-descriptor 
  +      <field-descriptor
            name="grabSize"
            column="GRAB_SIZE"
            jdbc-type="INTEGER"
         />
  +      <field-descriptor
  +         name="version"
  +         column="VERSION"
  +         jdbc-type="INTEGER"
  +         locking="true"
  +      />
      </class-descriptor>
   
   
  @@ -35,29 +41,29 @@
      	  class="org.apache.ojb.odmg.locking.LockEntry"
      	  table="OJB_LOCKENTRY"
      >
  -      <field-descriptor 
  +      <field-descriptor
            name="oidString"
            column="OID_"
            jdbc-type="VARCHAR"
            primarykey="true"
         />
  -      <field-descriptor 
  +      <field-descriptor
            name="transactionId"
            column="TX_ID"
            jdbc-type="VARCHAR"
            primarykey="true"
         />
  -      <field-descriptor 
  +      <field-descriptor
            name="timestamp"
            column="TIMESTAMP_"
            jdbc-type="BIGINT"
         />
  -      <field-descriptor 
  +      <field-descriptor
            name="isolationLevel"
            column="ISOLATIONLEVEL"
            jdbc-type="INTEGER"
         />
  -      <field-descriptor 
  +      <field-descriptor
            name="lockType"
            column="LOCKTYPE"
            jdbc-type="INTEGER"
  @@ -70,13 +76,13 @@
      	  class="org.apache.ojb.odmg.NamedRootsEntry"
      	  table="OJB_NRM"
      >
  -      <field-descriptor 
  +      <field-descriptor
            name="name"
            column="NAME"
            jdbc-type="VARCHAR"
            primarykey="true"
         />
  -      <field-descriptor 
  +      <field-descriptor
            name="oid"
            column="OID_"
            jdbc-type="LONGVARBINARY"
  @@ -88,14 +94,14 @@
      	  class="org.apache.ojb.odmg.collections.DListImpl"
      	  table="OJB_DLIST"
      >
  -      <field-descriptor 
  +      <field-descriptor
            name="id"
            column="ID"
            jdbc-type="INTEGER"
            primarykey="true"
            autoincrement="true"
         />
  -      <field-descriptor 
  +      <field-descriptor
            name="size"
            column="SIZE_"
            jdbc-type="INTEGER"
  @@ -125,12 +131,12 @@
            column="DLIST_ID"
            jdbc-type="INTEGER"
         />
  -      <field-descriptor 
  +      <field-descriptor
            name="position"
            column="POSITION_"
            jdbc-type="INTEGER"
         />
  -      <field-descriptor 
  +      <field-descriptor
            name="oid"
            column="OID_"
            jdbc-type="LONGVARBINARY"
  @@ -143,14 +149,14 @@
      	  class="org.apache.ojb.odmg.collections.DBagImpl"
      	  table="OJB_DLIST"
      >
  -      <field-descriptor 
  +      <field-descriptor
            name="id"
            column="ID"
            jdbc-type="INTEGER"
            primarykey="true"
            autoincrement="true"
         />
  -      <field-descriptor 
  +      <field-descriptor
            name="size"
            column="SIZE_"
            jdbc-type="INTEGER"
  @@ -168,14 +174,14 @@
      	  class="org.apache.ojb.odmg.collections.DSetImpl"
      	  table="OJB_DSET"
      >
  -      <field-descriptor 
  +      <field-descriptor
            name="id"
            column="ID"
            jdbc-type="INTEGER"
            primarykey="true"
            autoincrement="true"
         />
  -      <field-descriptor 
  +      <field-descriptor
            name="size"
            column="SIZE_"
            jdbc-type="INTEGER"
  @@ -193,24 +199,24 @@
      	  class="org.apache.ojb.odmg.collections.DSetEntry"
      	  table="OJB_DSET_ENTRIES"
      >
  -      <field-descriptor 
  +      <field-descriptor
            name="id"
            column="ID"
            jdbc-type="INTEGER"
            primarykey="true"
            autoincrement="true"
         />
  -      <field-descriptor 
  +      <field-descriptor
            name="dlistId"
            column="DLIST_ID"
            jdbc-type="INTEGER"
         />
  -      <field-descriptor 
  +      <field-descriptor
            name="position"
            column="POSITION_"
            jdbc-type="INTEGER"
         />
  -      <field-descriptor 
  +      <field-descriptor
            name="oid"
            column="OID_"
            jdbc-type="LONGVARBINARY"
  @@ -223,14 +229,14 @@
      	  class="org.apache.ojb.odmg.collections.DMapImpl"
      	  table="OJB_DMAP"
      >
  -      <field-descriptor 
  +      <field-descriptor
            name="id"
            column="ID"
            jdbc-type="INTEGER"
            primarykey="true"
            autoincrement="true"
         />
  -      <field-descriptor 
  +      <field-descriptor
            name="size"
            column="SIZE_"
            jdbc-type="INTEGER"
  @@ -261,13 +267,13 @@
            column="DMAP_ID"
            jdbc-type="INTEGER"
         />
  -      <field-descriptor 
  +      <field-descriptor
            name="keyOID"
            column="KEY_OID"
            jdbc-type="LONGVARBINARY"
            conversion="org.apache.ojb.broker.accesslayer.conversions.Object2ByteArrFieldConversion"
         />
  -      <field-descriptor 
  +      <field-descriptor
            name="valueOID"
            column="VALUE_OID"
            jdbc-type="LONGVARBINARY"
  
  
  
  1.10      +3 -0      db-ojb/src/test/org/apache/ojb/repository_database.xml
  
  Index: repository_database.xml
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/repository_database.xml,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- repository_database.xml	26 Feb 2003 00:00:15 -0000	1.9
  +++ repository_database.xml	1 Apr 2003 14:06:11 -0000	1.10
  @@ -26,6 +26,7 @@
      		dbalias="@URL_DBALIAS@"
      		username="@USER_NAME@"
      		password="@USER_PASSWD@"
  +        eager-release="false"
      		batch-mode="false"
           useAutoCommit="1"
           ignoreAutoCommitExceptions="false"
  @@ -37,6 +38,8 @@
   
           <sequence-manager className="org.apache.ojb.broker.util.sequence.SequenceManagerHighLowImpl">
               <attribute attribute-name="grabSize" attribute-value="20"/>
  +            <attribute attribute-name="globalSequenceId" attribute-value="false"/>
  +            <attribute attribute-name="globalSequenceStart" attribute-value="10000"/>
           </sequence-manager>
      </jdbc-connection-descriptor>
   
  
  
  
  1.38      +6 -28     db-ojb/src/test/org/apache/ojb/repository.dtd
  
  Index: repository.dtd
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/repository.dtd,v
  retrieving revision 1.37
  retrieving revision 1.38
  diff -u -r1.37 -r1.38
  --- repository.dtd	30 Mar 2003 15:02:39 -0000	1.37
  +++ repository.dtd	1 Apr 2003 14:06:11 -0000	1.38
  @@ -240,10 +240,11 @@
       manager implementation used for key generation. All
       sequence manager implementations shipped with OJB
       you will find under org.apache.ojb.broker.util.sequence
  -    If no sequence-manager is defined, OJB use the default one.
  +    If no sequence-manager is defined, OJB use a default one.
  +    For configuration examples please consult documentation.
   
       Use the attribute element to pass implementation specific
  -    properties.
  +    properties. This depends on the used implementation class.
   -->
   <!ELEMENT sequence-manager (documentation?, attribute*)>
   
  @@ -252,31 +253,8 @@
       of the desired sequence manager implementation - it is mandatory
       when using the sequence-manager element.
       All sequence manager implementations you find will under
  -    org.apache.ojb.broker.util.sequence package named as SequenceManagerXXXImpl
  -
  -    Sequence Manager implementations
  -
  -    1. className="org.apache.ojb.broker.util.sequence.SequenceManagerHighLowImpl"
  -    High/Low sequence manager implementation. This is OJB's default sequence manager.
  -
  -    2. className=org.apache.ojb.broker.util.sequence.SequenceManagerInMemoryImpl
  -    InMemory-sequence manager implementation.
  -    This is the fastest standard sequence manager implementation, but
  -    has some limitations:
  -    - do not use in client/server mode
  -    - do not use in clustered environments
  -    - do not use if other entities generate id's for the persistent objects
  -
  -    3. className=org.apache.ojb.broker.util.sequence.SequenceManagerNextValImpl
  -    Use database based sequence generation. Check your DB for support, add
  -    a extent aware 'sequence-name' attribute to your autoincrement field
  -    descriptors. If no sequence-name was found by the implementation,
  -    an extent aware sequence name is build by it's own.
  -
  -    4. className=org.apache.ojb.broker.util.sequence.SequenceManagerSeqNextValImpl
  -    A database sequence based High/Low implementation. See 3. for more informantion.
  -    Limitations:
  -    - do not use when other applications use the database sequence ditto
  +    org.apache.ojb.broker.util.sequence package named as SequenceManagerXXXImpl.
  +    For configuration examples please consult documentation.
   -->
   <!ATTLIST sequence-manager
       className                       CDATA #REQUIRED
  @@ -335,7 +313,7 @@
   	The optional initialization-method specifies a no-argument instance
   	method that is invoked after reading an instnace from a database row.
   	It can be used to do initialization and validations.
  -	
  +
   	The optional factory-method specifies a static no-argument method
   	that is to be used instead of a no argument constructor.
   	Important note: this feature is not yet implemented.
  
  
  
  1.5       +1 -1      db-ojb/src/test/org/apache/ojb/faraway-db/OJB_FarAway.script
  
  Index: OJB_FarAway.script
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/faraway-db/OJB_FarAway.script,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- OJB_FarAway.script	14 Jan 2003 11:16:20 -0000	1.4
  +++ OJB_FarAway.script	1 Apr 2003 14:06:11 -0000	1.5
  @@ -1,6 +1,6 @@
   CREATE TABLE FAR_AWAY(ID INTEGER PRIMARY KEY,NAME VARCHAR(50),DESCRIPTION VARCHAR(250), REFERENCE_ID INTEGER)
   CREATE TABLE FAR_AWAY_REFERENCE(ID INTEGER PRIMARY KEY,NAME VARCHAR(50))
  -CREATE TABLE OJB_HL_SEQ(TABLENAME VARCHAR(175) NOT NULL,FIELDNAME VARCHAR(70) NOT NULL,MAX_KEY INTEGER,GRAB_SIZE INTEGER,CONSTRAINT SYS_PK_OJB_HL_SEQ PRIMARY KEY(TABLENAME,FIELDNAME))
  +CREATE TABLE OJB_HL_SEQ(TABLENAME VARCHAR(175) NOT NULL,FIELDNAME VARCHAR(70) NOT NULL,MAX_KEY INTEGER,GRAB_SIZE INTEGER,VERSION INTEGER,CONSTRAINT SYS_PK_OJB_HL_SEQ PRIMARY KEY(TABLENAME,FIELDNAME))
   CREATE TABLE OJB_LOCKENTRY(OID_ VARCHAR(250) NOT NULL,TX_ID VARCHAR(50) NOT NULL,TIMESTAMP_ TIMESTAMP,ISOLATIONLEVEL INTEGER,LOCKTYPE INTEGER,CONSTRAINT SYS_PK_OJB_LOCKENTRY PRIMARY KEY(OID_,TX_ID))
   CREATE TABLE OJB_NRM(NAME VARCHAR(250) NOT NULL PRIMARY KEY,OID_ LONGVARBINARY)
   CREATE TABLE OJB_DLIST(ID INTEGER NOT NULL PRIMARY KEY,SIZE_ INTEGER)
  
  
  
  1.3       +10 -6     db-ojb/src/test/org/apache/ojb/broker/Role.java
  
  Index: Role.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/Role.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Role.java	6 Oct 2002 14:25:54 -0000	1.2
  +++ Role.java	1 Apr 2003 14:06:11 -0000	1.3
  @@ -25,21 +25,18 @@
    */
   package org.apache.ojb.broker;
   
  +import org.apache.commons.lang.builder.ToStringBuilder;
  +
   import java.util.Collection;
   import java.io.Serializable;
   
   public class Role implements Serializable
   {
       private int person_id;
  -
       private int project_id;
  -
       private Person person;
  -
       private Project project;
  -
       private String roleName;
  -
       private Collection tasks;
   
       public Role()
  @@ -116,6 +113,13 @@
   
       public String toString()
       {
  -        return person.getFirstname() + " is " + roleName + " of " + project.getTitle();
  +        ToStringBuilder buf = new ToStringBuilder(this);
  +        buf.append("roleName", roleName).
  +        append("personId", person_id).
  +        append("person", person).
  +        append("projectId", project_id).
  +        append("project", project).
  +        append("tasks", tasks);
  +        return buf.toString();
       }
   }
  
  
  
  1.4       +6 -5      db-ojb/src/test/org/apache/ojb/broker/ReferenceTest.java
  
  Index: ReferenceTest.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/ReferenceTest.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ReferenceTest.java	12 Mar 2003 18:38:35 -0000	1.3
  +++ ReferenceTest.java	1 Apr 2003 14:06:11 -0000	1.4
  @@ -7,6 +7,7 @@
   
   import java.util.Collection;
   import java.util.Iterator;
  +import java.io.Serializable;
   
   /**
    * Test case for checking the management of references.
  @@ -283,7 +284,7 @@
   // Inner classes used by the test case
   //***************************************************************************
   
  -    public static class Repository
  +    public static class Repository implements Serializable
       {
           private Integer repId;
   
  @@ -348,7 +349,7 @@
   
       }
   
  -    public static interface ReferenceIF
  +    public static interface ReferenceIF extends Serializable
       {
           Integer getRefId();
   
  @@ -359,14 +360,14 @@
           void setName(String name);
       }
   
  -    public static interface ReferenceAIF
  +    public static interface ReferenceAIF extends Serializable
       {
           String getRefNameA();
   
           void setRefNameA(String name);
       }
   
  -    public static interface ReferenceBIF
  +    public static interface ReferenceBIF extends Serializable
       {
           String getRefNameB();
   
  
  
  
  1.8       +23 -0     db-ojb/src/test/org/apache/ojb/broker/MultipleDBTest.java
  
  Index: MultipleDBTest.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/MultipleDBTest.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- MultipleDBTest.java	5 Feb 2003 20:03:41 -0000	1.7
  +++ MultipleDBTest.java	1 Apr 2003 14:06:11 -0000	1.8
  @@ -6,6 +6,8 @@
   import org.apache.ojb.broker.query.QueryByCriteria;
   import org.apache.ojb.broker.query.Criteria;
   
  +import java.sql.Connection;
  +
   /**
    * Test to check support for multiple DB.
    *
  @@ -32,6 +34,27 @@
       {
           String[] arr = {MultipleDBTest.class.getName()};
           junit.textui.TestRunner.main(arr);
  +    }
  +
  +    public void testPBLookup() throws Exception
  +    {
  +        PBKey key = new PBKey(TestHelper.FAR_AWAY_JCD_ALIAS);
  +        PersistenceBroker broker = PersistenceBrokerFactory.createPersistenceBroker(key);
  +        // get connection to check lookup
  +        Connection con = broker.serviceConnectionManager().getConnection();
  +        con.isClosed();
  +        assertNotNull(broker);
  +        assertEquals(key.getAlias(), broker.getPBKey().getAlias());
  +        broker.close();
  +
  +        key = new PBKey(TestHelper.DEF_JCD_ALIAS);
  +        broker = PersistenceBrokerFactory.createPersistenceBroker(key);
  +        // get connection to check lookup
  +        con = broker.serviceConnectionManager().getConnection();
  +        con.isClosed();
  +        assertNotNull(broker);
  +        assertEquals(key.getAlias(), broker.getPBKey().getAlias());
  +        broker.close();
       }
   
       public void testPBCreation() throws Exception
  
  
  
  1.2       +4 -2      db-ojb/src/test/org/apache/ojb/broker/FarAwayReference.java
  
  Index: FarAwayReference.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/FarAwayReference.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- FarAwayReference.java	25 Sep 2002 14:39:35 -0000	1.1
  +++ FarAwayReference.java	1 Apr 2003 14:06:11 -0000	1.2
  @@ -1,11 +1,13 @@
   package org.apache.ojb.broker;
   
  +import java.io.Serializable;
  +
   /**
    *
    * @author <a href="mailto:armin@codeAuLait.de">Armin Waibel</a>
    * @version $Id$
    */
  -public class FarAwayReference
  +public class FarAwayReference implements Serializable
   {
       private String name;
       private int id;
  
  
  
  1.3       +4 -2      db-ojb/src/test/org/apache/ojb/broker/FarAwayClass.java
  
  Index: FarAwayClass.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/FarAwayClass.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- FarAwayClass.java	25 Sep 2002 14:39:35 -0000	1.2
  +++ FarAwayClass.java	1 Apr 2003 14:06:11 -0000	1.3
  @@ -1,11 +1,13 @@
   package org.apache.ojb.broker;
   
  +import java.io.Serializable;
  +
   /**
    *
    * @author <a href="mailto:armin@codeAuLait.de">Armin Waibel</a>
    * @version $Id$
    */
  -public class FarAwayClass
  +public class FarAwayClass implements Serializable
   {
       private String name;
       private int id;
  
  
  
  1.2       +4 -2      db-ojb/src/test/org/apache/ojb/broker/sequence/SMSameTableB.java
  
  Index: SMSameTableB.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/sequence/SMSameTableB.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SMSameTableB.java	28 Oct 2002 15:48:35 -0000	1.1
  +++ SMSameTableB.java	1 Apr 2003 14:06:12 -0000	1.2
  @@ -1,11 +1,13 @@
   package org.apache.ojb.broker.sequence;
   
  +import java.io.Serializable;
  +
   /**
    *
    * @author <a href="mailto:armin@codeAuLait.de">Armin Waibel</a>
    * @version $Id$
    */
  -public class SMSameTableB
  +public class SMSameTableB implements Serializable
   {
       private Integer id;
       private String name;
  
  
  
  1.2       +4 -2      db-ojb/src/test/org/apache/ojb/broker/sequence/SMSameTableA.java
  
  Index: SMSameTableA.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/sequence/SMSameTableA.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SMSameTableA.java	28 Oct 2002 15:48:35 -0000	1.1
  +++ SMSameTableA.java	1 Apr 2003 14:06:12 -0000	1.2
  @@ -1,11 +1,13 @@
   package org.apache.ojb.broker.sequence;
   
  +import java.io.Serializable;
  +
   /**
    *
    * @author <a href="mailto:armin@codeAuLait.de">Armin Waibel</a>
    * @version $Id$
    */
  -public class SMSameTableA
  +public class SMSameTableA implements Serializable
   {
       private Integer id;
       private String name;
  
  
  
  1.2       +4 -2      db-ojb/src/test/org/apache/ojb/broker/sequence/SMMax.java
  
  Index: SMMax.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/sequence/SMMax.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SMMax.java	9 Nov 2002 19:15:39 -0000	1.1
  +++ SMMax.java	1 Apr 2003 14:06:12 -0000	1.2
  @@ -1,11 +1,13 @@
   package org.apache.ojb.broker.sequence;
   
  +import java.io.Serializable;
  +
   /**
    *
    * @author <a href="mailto:armin@codeAuLait.de">Armin Waibel</a>
    * @version $Id$
    */
  -public interface SMMax
  +public interface SMMax extends Serializable
   {
       public Integer getId();
       public void setId(Integer id);
  
  
  
  1.3       +4 -2      db-ojb/src/test/org/apache/ojb/broker/sequence/SMKey.java
  
  Index: SMKey.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/sequence/SMKey.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- SMKey.java	23 Nov 2002 09:56:45 -0000	1.2
  +++ SMKey.java	1 Apr 2003 14:06:12 -0000	1.3
  @@ -1,12 +1,14 @@
   package org.apache.ojb.broker.sequence;
   
  +import java.io.Serializable;
  +
   /**
    * Test class with multiple autoincrement fields defined in repository.
    *
    * @author <a href="mailto:armin@codeAuLait.de">Armin Waibel</a>
    * @version $Id$
    */
  -public class SMKey
  +public class SMKey implements Serializable
   {
       private int intKey;
       private String name;
  
  
  
  1.18      +93 -43    db-ojb/src/test/org/apache/ojb/broker/sequence/SequenceManagerTest.java
  
  Index: SequenceManagerTest.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/sequence/SequenceManagerTest.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- SequenceManagerTest.java	8 Mar 2003 19:22:55 -0000	1.17
  +++ SequenceManagerTest.java	1 Apr 2003 14:06:12 -0000	1.18
  @@ -9,6 +9,8 @@
   import org.apache.ojb.broker.*;
   import org.apache.ojb.broker.metadata.FieldDescriptor;
   import org.apache.ojb.broker.metadata.SequenceDescriptor;
  +import org.apache.ojb.broker.metadata.MetadataManager;
  +import org.apache.ojb.broker.metadata.JdbcConnectionDescriptor;
   import org.apache.ojb.broker.query.Criteria;
   import org.apache.ojb.broker.query.Query;
   import org.apache.ojb.broker.query.QueryByCriteria;
  @@ -19,6 +21,8 @@
   import org.apache.ojb.broker.util.sequence.SequenceManagerHighLowImpl;
   import org.apache.ojb.broker.util.sequence.SequenceManagerNextValImpl;
   import org.apache.ojb.broker.util.sequence.SequenceManagerSeqHiLoImpl;
  +import org.apache.ojb.broker.util.sequence.SequenceManagerStoredProcedureImpl;
  +import org.apache.commons.lang.SerializationUtils;
   
   /**
    * Tests to verify SequenceManager implementations - All sequence
  @@ -135,7 +139,7 @@
        */
       public void testMultipleAutoincrement()
       {
  -        String MESSAGE = "Autoincrement field was not set: ";
  +        String MESSAGE = "Autoincrement field was not incremented: ";
           String name = "my test key " + System.currentTimeMillis();
           SMKey key = new SMKey();
           key.setName(name);
  @@ -220,15 +224,15 @@
   
           // find max from classes using different tables
           FieldDescriptor field = broker.getClassDescriptor(SMMax.class).getAutoIncrementField();
  -        int result1 = SequenceManagerHelper.getMaxForExtent(broker, field);
  +        long result1 = SequenceManagerHelper.getMaxForExtent(broker, field);
           field = broker.getClassDescriptor(SMMaxA.class).getAutoIncrementField();
  -        int result2 = SequenceManagerHelper.getMaxForExtent(broker, field);
  +        long result2 = SequenceManagerHelper.getMaxForExtent(broker, field);
           field = broker.getClassDescriptor(SMMaxAA.class).getAutoIncrementField();
  -        int result3 = SequenceManagerHelper.getMaxForExtent(broker, field);
  +        long result3 = SequenceManagerHelper.getMaxForExtent(broker, field);
           field = broker.getClassDescriptor(SMMaxAB.class).getAutoIncrementField();
  -        int result4 = SequenceManagerHelper.getMaxForExtent(broker, field);
  +        long result4 = SequenceManagerHelper.getMaxForExtent(broker, field);
           field = broker.getClassDescriptor(SMMaxAAA.class).getAutoIncrementField();
  -        int result5 = SequenceManagerHelper.getMaxForExtent(broker, field);
  +        long result5 = SequenceManagerHelper.getMaxForExtent(broker, field);
   
           assertEquals(SMMAX_FAIL_MESSAGE, SMMAX_MAX_PK_VALUE, result1);
           assertEquals(SMMAX_FAIL_MESSAGE, SMMAX_MAX_PK_VALUE, result2);
  @@ -254,7 +258,7 @@
           broker.store(new C());
           broker.store(new D());
           broker.commitTransaction();
  -        int[] result = new int[5];
  +        long[] result = new long[5];
           FieldDescriptor field = broker.getClassDescriptor(A.class).getAutoIncrementField();
           result[0] = SequenceManagerHelper.getMaxForExtent(broker, field);
           field = broker.getClassDescriptor(B.class).getAutoIncrementField();
  @@ -286,7 +290,7 @@
       public void testMaxKeySearch3()
       {
           PersistenceBroker broker = PersistenceBrokerFactory.defaultPersistenceBroker();
  -        int[] result = new int[5];
  +        long[] result = new long[5];
           FieldDescriptor field = broker.getClassDescriptor(Article.class).getAutoIncrementField();
           result[0] = SequenceManagerHelper.getMaxForExtent(broker, field);
           field = broker.getClassDescriptor(AbstractArticle.class).getAutoIncrementField();
  @@ -430,17 +434,48 @@
           int id2 = val.intValue();
           assertTrue(id1 != id2);
           assertTrue(id2 > id1);
  -        assertTrue((id2 - id1) == 1);
  +        assertTrue("If the sequence manger implementation does not support continuous key generation"+
  +        " per PB instance, you could ignore this failure", (id2 - id1) == 1);
  +    }
  +
  +    /**
  +     * Tests the generation of unique sequence numbers
  +     * in multi-threaded environment.
  +     */
  +    public void testSequenceGeneration()
  +    {
  +        long time = System.currentTimeMillis();
  +        generateKeys();
  +        time = System.currentTimeMillis() - time;
  +        System.out.println(this.getClass().getName() + ": " + time + " (ms) time for key generating");
  +        analyseUniqueness(generatedKeys);
  +    }
  +
  +    /**
  +     * Tests to detect the lost of sequence numbers
  +     * in multi-threaded environments.
  +     */
  +    public void testForLostKeys()
  +    {
  +        generateKeys();
  +        TreeSet set = new TreeSet((List) generatedKeys.clone());
  +        if (set.isEmpty()) fail("No generated keys found");
  +        int result = ((Integer) set.last()).intValue() - ((Integer) set.first()).intValue() + 1;
  +        assertEquals("Sequence manager lost sequence numbers, this could be a failure or could be"+
  +                " the volitional behaviour of the sequence manager"+
  +                " - retry test case, check test case, check sequence manager implementation.", keyCount, result);
       }
   
       /**
  -     * Test for unique continious key generation
  +     * Test for unique **continuous** key generation
        * across different PB instances.
        *
        * test case was written by a user - thanks.
  -     * this test was *commented out* by default.
  +     * this test was *commented out* by default, because
  +     * not all sequence manager implementations generate continuous keys
  +     * across different PB instances.
        */
  -    public void XXXtest_getUniqueIdWithTwoBrokers() throws Exception
  +    public void YYYtest_getUniqueIdWithTwoBrokers() throws Exception
       {
           PersistenceBroker pb = PersistenceBrokerFactory.defaultPersistenceBroker();
           PersistenceBroker pb2 = PersistenceBrokerFactory.defaultPersistenceBroker();
  @@ -448,62 +483,77 @@
   
           Integer val = (Integer) pb.serviceSequenceManager().getUniqueValue(field);
           int id1 = val.intValue();
  -        
  +
           val = (Integer) pb2.serviceSequenceManager().getUniqueValue(field);
           int id2 = val.intValue();
  -        
  +
           assertTrue(id1 != id2);
           assertTrue(id2 > id1);
           assertTrue((id2 - id1) == 1);
   
           val = (Integer) pb2.serviceSequenceManager().getUniqueValue(field);
           id1 = val.intValue();
  -        
  +
           val = (Integer) pb.serviceSequenceManager().getUniqueValue(field);
           id2 = val.intValue();
  -         
  +
           assertTrue(id1 != id2);
           assertTrue(id2 > id1);
           assertTrue((id2 - id1) == 1);
   
           val = (Integer) pb.serviceSequenceManager().getUniqueValue(field);
           id1 = val.intValue();
  -        
  +
           val = (Integer) pb2.serviceSequenceManager().getUniqueValue(field);
           id2 = val.intValue();
   
  -        
  +
           assertTrue(id1 != id2);
           assertTrue(id2 > id1);
           assertTrue((id2 - id1) == 1);
       }
   
       /**
  -     * Tests the generation of unique sequence numbers
  -     * in multi-threaded environment.
  +     * Test case for internal use while developing!
  +     * Was commented out by default!
        */
  -    public void testSequenceGeneration()
  +    public void YYYtestSequenceManagerStoredProcedureImpl() throws Exception
       {
  -        long time = System.currentTimeMillis();
  -        generateKeys();
  -        time = System.currentTimeMillis() - time;
  -        System.out.println(this.getClass().getName() + ": " + time + " (ms) time for key generating");
  -        analyseUniqueness(generatedKeys);
  -    }
  +        JdbcConnectionDescriptor jcd = MetadataManager.getInstance().connectionRepository().
  +                                        getDescriptor(PersistenceBrokerFactory.getDefaultKey());
  +        SequenceDescriptor old_sd = (SequenceDescriptor) SerializationUtils.clone(jcd.getSequenceDescriptor());
  +        PersistenceBroker broker;
  +        try
  +        {
  +            jcd.setSequenceDescriptor(new SequenceDescriptor(jcd, SequenceManagerStoredProcedureImpl.class));
  +            PersistenceBrokerFactory.releaseAllInstances();
  +            broker = PersistenceBrokerFactory.defaultPersistenceBroker();
  +            SequenceManager sm = broker.serviceSequenceManager();
  +            if(! (sm instanceof SequenceManagerStoredProcedureImpl))
  +            {
  +                fail("testSM_StoredProcedure: Expected sequence manager implemenation was "+
  +                        SequenceManagerStoredProcedureImpl.class.getName());
  +                return;
  +            }
  +            // now we start the tests
  +            FieldDescriptor field = broker.getClassDescriptor(targetClass).getAutoIncrementField();
  +            sm.getUniqueValue(field);
  +
  +            generatedKeys.clear();
  +            testSequenceGeneration();
  +            testMultipleAutoincrement();
  +            testSequenceNameAttribute();
  +            broker.close();
  +        }
  +        finally
  +        {
  +            if(old_sd != null)
  +            {
   
  -    /**
  -     * Tests to detect the lost of sequence numbers
  -     * in multi-threaded environments.
  -     */
  -    public void testForLostKeys()
  -    {
  -        generateKeys();
  -        TreeSet set = new TreeSet((List) generatedKeys.clone());
  -        if (set.isEmpty()) fail("No generated keys found");
  -        int result = ((Integer) set.last()).intValue() - ((Integer) set.first()).intValue() + 1;
  -        assertEquals("Sequence manager lost sequence numbers, this could be a failure or could be"+
  -                " the volitional behaviour of the sequence manager"+
  -                " - retry test case, check test case, check sequence manager implementation.", keyCount, result);
  +                PersistenceBrokerFactory.releaseAllInstances();
  +                jcd.setSequenceDescriptor(old_sd);
  +            }
  +        }
       }
   
       private void generateKeys()
  @@ -559,12 +609,12 @@
   
       protected static synchronized void addResultList(List resultList)
       {
  -        System.out.println("add "+ resultList.size() +"generated Keys");
  +        System.out.println(" add "+ resultList.size() +"generated Keys");
           if (resultList == null) return;
           generatedKeys.addAll(resultList);
       }
   
  -    protected static void countKey()
  +    protected static synchronized void countKey()
       {
           ++keyCount;
       }
  
  
  
  1.4       +1 -0      db-ojb/src/schema/ojbcore-schema.xml
  
  Index: ojbcore-schema.xml
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/schema/ojbcore-schema.xml,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ojbcore-schema.xml	9 Nov 2002 17:11:30 -0000	1.3
  +++ ojbcore-schema.xml	1 Apr 2003 14:06:12 -0000	1.4
  @@ -8,6 +8,7 @@
       <column name="FIELDNAME" required="true" primaryKey="true" type="VARCHAR" size="70"/>
       <column name="MAX_KEY" type="INTEGER"/>
       <column name="GRAB_SIZE" type="INTEGER"/>
  +    <column name="VERSION" type="INTEGER"/>
     </table>
   
     <table name="OJB_LOCKENTRY" description="OJB Lock table">
  
  
  

Mime
View raw message