db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arm...@apache.org
Subject svn commit: r464345 - /db/ojb/branches/OJB_1_0_RELEASE/src/doc/forrest/src/documentation/content/xdocs/docu/guides/sequencemanager.xml
Date Mon, 16 Oct 2006 00:53:47 GMT
Author: arminw
Date: Sun Oct 15 17:53:46 2006
New Revision: 464345

URL: http://svn.apache.org/viewvc?view=rev&rev=464345
Log:
add support for 
-stored procedure based sequence key generation
-per field sequence manager declaration
-renamed/changed attributes

Modified:
    db/ojb/branches/OJB_1_0_RELEASE/src/doc/forrest/src/documentation/content/xdocs/docu/guides/sequencemanager.xml

Modified: db/ojb/branches/OJB_1_0_RELEASE/src/doc/forrest/src/documentation/content/xdocs/docu/guides/sequencemanager.xml
URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/doc/forrest/src/documentation/content/xdocs/docu/guides/sequencemanager.xml?view=diff&rev=464345&r1=464344&r2=464345
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/doc/forrest/src/documentation/content/xdocs/docu/guides/sequencemanager.xml
(original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/doc/forrest/src/documentation/content/xdocs/docu/guides/sequencemanager.xml
Sun Oct 15 17:53:46 2006
@@ -72,7 +72,9 @@
                     this column is
                     <code>INTEGER</code>. This
                     is a primary key column and OJB shall automatically assign unique values
-                    to this attribute.
+                    to this attribute using the default
+                    <a href="ext:sequence-manager"><code>SequenceManager</code></a>
defined within the
+                    <a href="site:jdbc-connection-descriptor"><code>jdbc-connection-descriptor</code></a>.
                 </p>
 
                 <p>
@@ -83,6 +85,118 @@
             </section>
 
 
+
+            <section>
+                <title>How to enable/change the sequence manager?</title>
+                <p>
+                    To enable a (specific)
+                    <a href="ext:sequence-manager"><code>SequenceManager</code></a>
implementation for automatic
+                    assignment of unquie values declare a <em>sequence-manager</em>
element within the
+                    <a href="site:jdbc-connection-descriptor">jdbc-connection-descriptor</a>
in the
+                    <a href="site:repository">repository file</a>.
+                    <br/>
+                    If no <em>sequence-manager</em> is specified in the
+                    <em>jdbc-connection-descriptor</em>, OJB use a default sequence
manager implementation
+                    (default is <a href="#in-memory"><em>SequenceManagerInMemoryImpl</em></a>).
+                </p>
+                <p>
+                    Further information you could find in the
+                    <a href="ext:repository.dtd">repository.dtd</a> section sequence-manager
element.
+                </p>
+                <p>
+                    Example
+                    <em>jdbc-connection-descriptor</em> using
+                    a <em>sequence-manager</em> tag:
+                </p>
+                <source><![CDATA[
+<jdbc-connection-descriptor
+        jcd-alias="farAway"
+        platform="Hsqldb"
+        jdbc-level="2.0"
+        driver="org.hsqldb.jdbcDriver"
+        protocol="jdbc"
+        subprotocol="hsqldb"
+        dbalias="../OJB_FarAway"
+        username="sa"
+        password=""
+        batch-mode="false"
+    >
+
+    <connection-pool
+        maxActive="5"
+        whenExhaustedAction="0"
+        validationQuery="select count(*) from OJB_HL_SEQ"
+    />
+
+    <sequence-manager className="org.apache.ojb.broker.util.sequence.SequenceManagerHighLowImpl">
+        <attribute attribute-name="seq.start" attribute-value="10000"/>
+        <attribute attribute-name="seq.grabSize" attribute-value="20"/>
+    </sequence-manager>
+</jdbc-connection-descriptor>]]></source>
+                <p>
+                    The mandatory
+                    <em>className</em> attribute needs the <strong>full-qualified
class name</strong>
+                    of the desired sequence-manager implementation or the OJB-shortcut name
(since OJB 1.0.5, all
+                    shipped implementations can be declared via a shortcut name - more details
see description
+                    of the implementation).
+                    <br/>
+                    If a implementation needs configuration properties you pass them using
+                    <a href="site:repository/custom-attribute">custom attribute</a>
tags with
+                    <em>attribute-name</em> represents the property name and
+                    <em>attribute-value</em> the property value.
+                    Each sequence manager implementation shows all properties in the implementation
+                    documentation section or on the according javadoc page.
+                </p>
+
+                <anchor id="per-field-sequence"/>
+                <section>
+                    <title>Define specific <code>SequenceManager</code>
for each <code>FieldDescriptor</code></title>
+                    <p>
+                        By default this feature is disabled. Enable it by setting attribute
<em>'seq.perField'</em>
+                        within the global (default) sequence manager element within the
+                        <a href="site:repository/jdbc-connection-descriptor">jdbc-connection-descriptor</a>:
+                    </p>
+                    <source><![CDATA[
+<jdbc-connection-descriptor ...>
+...
+    <sequence-manager className="hilo">
+        <!-- The attribute 'seq.perField': If set 'true' it's possible to define per
+        field-descriptor sequence manager. This way you can use different sequence
+        identifier generation strategies. If set 'false' only the default sequence manager
+        defined within the jdbc-connection-descriptor is used and all sequence descriptors
defined
+        on field-descriptor level are ignored -->
+        <attribute attribute-name="seq.perField" attribute-value="true"/>
+        ...
+    </sequence-manager>
+</jdbc-connection-descriptor]]></source>
+                    <p>
+                        Now it's possible to associate specific
+                        <a href="site:repository/field-descriptor"><em>field-descriptor</em></a>
with other
+                        <em>sequence manager</em> implementations than the global
defined.
+                    </p>
+                    <source><![CDATA[
+<class-descriptor
+      class="my.Group"
+      table="GROUP"
+>
+    <field-descriptor name="id" column="ID" jdbc-type="INTEGER"
+             primarykey="true" autoincrement="true"
+    >
+       <sequence-manager className="memory"/>
+    </field-descriptor>
+...
+</class-descriptor>]]></source>
+                    <p>
+                        If <a href="site:faq/multiple-databases">multiple databases/connections</a>
are used
+                        enable per field sequences for each database. If attribute <em>'seq.perField'</em>
+                        is disabled all <em>sequence-manager</em> settings within
+                        <a href="site:repository/field-descriptor"><em>field-descriptor</em></a>
are ignored.
+                    </p>
+                </section>
+
+            </section>
+
+
             <anchor id="force-id"/>
             <section>
                 <title>Force computation of unique values</title>
@@ -176,67 +290,6 @@
 
 
             <section>
-                <title>How to change the sequence manager?</title>
-                <p>
-                    To enable a specific
-                    <a href="ext:sequence-manager"><code>SequenceManager</code></a>
implementation declare
-                    an <em>sequence-manager</em> attribute within the
-                    <a href="site:jdbc-connection-descriptor">jdbc-connection-descriptor</a>
-                    element in the <a href="site:repository">repository file</a>.
-                    <br/>
-                    If no <em>sequence-manager</em> was specified in the
-                    <em>jdbc-connection-descriptor</em>, OJB use a default sequence
manager implementation
-                    (default was <em>SequenceManagerHighLowImpl</em>).
-                </p>
-                <p>
-                    Further information you could find in the
-                    <a href="ext:repository.dtd">repository.dtd</a> section sequence-manager
element.
-                </p>
-                <p>
-                    Example
-                    <em>jdbc-connection-descriptor</em> using
-                    a <em>sequence-manager</em> tag:
-                </p>
-                <source><![CDATA[
-<jdbc-connection-descriptor
-        jcd-alias="farAway"
-        platform="Hsqldb"
-        jdbc-level="2.0"
-        driver="org.hsqldb.jdbcDriver"
-        protocol="jdbc"
-        subprotocol="hsqldb"
-        dbalias="../OJB_FarAway"
-        username="sa"
-        password=""
-        batch-mode="false"
-    >
-
-    <connection-pool
-        maxActive="5"
-        whenExhaustedAction="0"
-        validationQuery="select count(*) from OJB_HL_SEQ"
-    />
-
-    <sequence-manager className="org.apache.ojb.broker.util.sequence.SequenceManagerHighLowImpl">
-        <attribute attribute-name="seq.start" attribute-value="10000"/>
-        <attribute attribute-name="grabSize" attribute-value="20"/>
-    </sequence-manager>
-</jdbc-connection-descriptor>]]></source>
-                <p>
-                    The mandatory
-                    <em>className</em> attribute needs the <strong>full-qualified
class name</strong>
-                    of the desired sequence-manager implementation. If a implementation needs
configuration
-                    properties you pass them using
-                    <a href="site:repository/custom-attribute">custom attribute</a>
tags with
-                    <em>attribute-name</em> represents the property name and
-                    <em>attribute-value</em>
-                    the property value. Each sequence manager implementation shows all properties
on
-                    the according javadoc page.
-                </p>
-            </section>
-
-
-            <section>
                 <title>SequenceManager implementations</title>
                 <p>
                     Source code of all
@@ -253,7 +306,7 @@
                     <title>High/Low sequence manager</title>
                     <p>
                         The <a href="ext:sequence-manager">sequence manager</a>
implementation class
-                        <code>ojb.broker.util.sequence.SequenceManagerHighLowImpl</code>
+                        <code>org.apache.ojb.broker.util.sequence.SequenceManagerHighLowImpl</code>
                         and is able to generate ID's unique to a given object and
                         all <a href="site:advanced-technique/extents"><em>extent</em>
objects</a> declarated in the
                         objects class descriptor.
@@ -274,17 +327,19 @@
                         (called <em>repository_internal.xml</em>)</a>.
                     </p>
                     <p>
-                        To declare this <em>sequence manager</em> implementation
specify a <code>sequence-manager</code>
+                        To enable this <em>sequence manager</em> implementation
specify a <code>sequence-manager</code>
                         element within the
-                        <a href="site:repository/jdbc-connection-descriptor">jdbc-connection-descriptor</a>:
+                        <a href="site:repository/jdbc-connection-descriptor">jdbc-connection-descriptor</a>
or
+                        <a href="site:repository/field-descriptor">field-descriptor</a>
+                        (<a href="#per-field-sequence">since OJB 1.0.5</a>) and
specifiy
+                        the <em>full class name</em> or the shortcut name (since
OJB 1.0.5) <em>hilo</em>:
                     </p>
                     <source><![CDATA[
-<sequence-manager className=
-    "org.apache.ojb.broker.util.sequence.SequenceManagerHighLowImpl">
-
+<!--<sequence-manager className="org.apache.ojb.broker.util.sequence.SequenceManagerHighLowImpl">-->
+<sequence-manager className="hilo">
     <attribute attribute-name="seq.start" attribute-value="5000"/>
-    <attribute attribute-name="grabSize" attribute-value="20"/>
-    <attribute attribute-name="autoNaming" attribute-value="true"/>
+    <attribute attribute-name="seq.grabSize" attribute-value="20"/>
+    <attribute attribute-name="seq.autoNaming" attribute-value="true"/>
     <attribute attribute-name="globalSequenceId" attribute-value="false"/>
     <!-- deprecated settings -->
     <attribute attribute-name="sequenceStart" attribute-value="5000"/>
@@ -299,10 +354,10 @@
                     </p>
                     <p>
                         With property
-                        <code>grabSize</code> you set the size of the assigned
ID's kept
+                        <code>seq.grabSize</code> you set the size of the assigned
ID's kept
                         in memory for each <em>autoincrement</em> field. If the
assigned ID's
                         are exhausted a database call is made to lookup the next bunch
-                        of ID's (default <em>grabSize</em> is 20).
+                        of ID's (default <em>seq.grabSize</em> is 20).
                         <br/>
                         If OJB was shutdown/redeployed all unused assigned ID's are lost.
                     </p>
@@ -323,10 +378,10 @@
                         to manage the sequences - more about
                         <a href="#sequence-name"><em>sequence-names</em>
here</a>.
                         <br/>
-                        The attribute <code>autoNaming</code> can be used to
enable <em>auto-generation</em>
+                        The attribute <code>seq.autoNaming</code> can be used
to enable <em>auto-generation</em>
                         of <em>sequence-names</em>, default value is <em>true</em>.
                         <br/>
-                        More info about attribute <a href="#auto-naming"><em>autoNaming</em>
here</a>.
+                        More info about attribute <a href="#auto-naming"><em>seq.autoNaming</em>
here</a>.
                     </p>
                     <p>
                         Limitations:
@@ -349,7 +404,7 @@
                         Another sequence manager implementation is a
                         <em>In-Memory</em> version
                         called
-                        <code>ojb.broker.util.sequence.SequenceManagerInMemoryImpl</code>.
+                        <code>org.apache.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
@@ -359,14 +414,18 @@
                         using the same mechanism as the High/Low sequence manager implementation.
                     </p>
                     <p>
-                        To declare this <em>sequence manager</em> implementation
specify a <code>sequence-manager</code>
+                        To enable this <em>sequence manager</em> implementation
specify a <code>sequence-manager</code>
                         element within the
-                        <a href="site:repository/jdbc-connection-descriptor">jdbc-connection-descriptor</a>:
+                        <a href="site:repository/jdbc-connection-descriptor">jdbc-connection-descriptor</a>
or
+                        <a href="site:repository/field-descriptor">field-descriptor</a>
+                        (<a href="#per-field-sequence">since OJB 1.0.5</a>) and
specifiy
+                        the <em>full class name</em> or the shortcut name (since
OJB 1.0.5) <em>memory</em>:
                     </p>
                     <source><![CDATA[
-<sequence-manager className="org.apache.ojb.broker.util.sequence.SequenceManagerInMemoryImpl">
+<!--<sequence-manager className="org.apache.ojb.broker.util.sequence.SequenceManagerInMemoryImpl">-->
+<sequence-manager className="memory">
     <attribute attribute-name="seq.start" attribute-value="0"/>
-    <attribute attribute-name="autoNaming" attribute-value="true"/>
+    <attribute attribute-name="seq.autoNaming" attribute-value="true"/>
 </sequence-manager>]]></source>
                     <p>
                         The property
@@ -381,10 +440,10 @@
                         sequence-names</em> as well as <em>automatic generated
sequence-names</em>
                         to manage the sequences - more about <a href="#sequence-name">sequence-names</a>.
                         <br/>
-                        The attribute <code>autoNaming</code> can be used to
enable <em>auto-generation</em>
+                        The attribute <code>seq.autoNaming</code> can be used
to enable <em>auto-generation</em>
                         of <em>sequence-names</em>, default value is <em>true</em>.
                         <br/>
-                        More info about <a href="#auto-naming">autoNaming</a>.
+                        More info about <a href="#auto-naming">seq.autoNaming</a>.
                     </p>
                     <p>
                         The specified sequences will only be used <em>in memory</em>.
First time a sequence was used
@@ -420,7 +479,7 @@
                         e.g. <code>CREATE SEQUENCE sequenceName</code>. This
implementation use database
                         based sequences to assign ID's in <em>autoincrement fields</em>.
                         <br/>
-                        The sequences can be managed by hand, by a database tool or by OJB.
If the <em>autoNaming</em>
+                        The sequences can be managed by hand, by a database tool or by OJB.
If the <em>seq.autoNaming</em>
                         attribute is enabled OJB creates sequences if needed. Also it's possible
to declare
                         <em>sequence names</em> in the <a href="site:repository/field-descriptor">field-descriptor</a>
                     </p>
@@ -441,14 +500,18 @@
 ....
 </class-descriptor>]]></source>
                     <p>
-                        To declare this <em>sequence manager</em> implementation
specify a <code>sequence-manager</code>
+                        To enable this <em>sequence manager</em> implementation
specify a <code>sequence-manager</code>
                         element within the
-                        <a href="site:repository/jdbc-connection-descriptor">jdbc-connection-descriptor</a>:
+                        <a href="site:repository/jdbc-connection-descriptor">jdbc-connection-descriptor</a>
or
+                        <a href="site:repository/field-descriptor">field-descriptor</a>
+                        (<a href="#per-field-sequence">since OJB 1.0.5</a>) and
specifiy
+                        the <em>full class name</em> or the shortcut name (since
OJB 1.0.5) <em>nextval</em>:
                     </p>
                     <source><![CDATA[
-<sequence-manager className="org.apache.ojb.broker.util.sequence.SequenceManagerNextValImpl">
+<!--<sequence-manager className="org.apache.ojb.broker.util.sequence.SequenceManagerNextValImpl">-->
+<sequence-manager className="nextval">
     <attribute attribute-name="seq.start" attribute-value="200000"/>
-    <attribute attribute-name="autoNaming" attribute-value="true"/>
+    <attribute attribute-name="seq.autoNaming" attribute-value="true"/>
 
     <!-- optional attributes supported by Oracle, PostgreSQL, MaxDB/SapDB, DB2 -->
     <!-- attribute attribute-name="seq.incrementBy" attribute-value="1"/ -->
@@ -460,11 +523,11 @@
 </sequence-manager>]]></source>
                     <p>
                         Attribute
-                        <code>autoNaming</code>, default setting is <em>true</em>.
If set <em>true</em> OJB will
+                        <code>seq.autoNaming</code>, default setting is <em>true</em>.
If set <em>true</em> OJB will
                         try to auto-generate a sequence name if none was found in
                         <a href="site:repository/field-descriptor">field-descriptor's</a>
                         <em>sequence-name</em> attribute and create a database
sequence if needed - more
-                        details see <a href="#auto-naming">autoNaming</a> section.
+                        details see <a href="#auto-naming">seq.autoNaming</a>
section.
                         <br/>
                         The auto-generated name will be set as
                         <a href="#sequence-name"><em>sequence-name</em></a>
in the <em>field-descriptor</em>.
@@ -597,17 +660,26 @@
                         <a href="#database-sequences-based">above</a>, but
                         use a high/low algorithm to avoid database access.
                     </p>
+                    <p>
+                        To enable this <em>sequence manager</em> implementation
specify a <code>sequence-manager</code>
+                        element within the
+                        <a href="site:repository/jdbc-connection-descriptor">jdbc-connection-descriptor</a>
or
+                        <a href="site:repository/field-descriptor">field-descriptor</a>
+                        (<a href="#per-field-sequence">since OJB 1.0.5</a>) and
specifiy
+                        the <em>full class name</em> or the shortcut name (since
OJB 1.0.5) <em>seqhilo</em>:
+                    </p>
                     <source><![CDATA[
-<sequence-manager className="org.apache.ojb.broker.util.sequence.SequenceManagerSeqHiLoImpl">
-    <attribute attribute-name="grabSize" attribute-value="20"/>
-    <attribute attribute-name="autoNaming" attribute-value="true"/>
+<!--<sequence-manager className="org.apache.ojb.broker.util.sequence.SequenceManagerSeqHiLoImpl">-->
+<sequence-manager className="seqhilo">
+    <attribute attribute-name="seq.grabSize" attribute-value="20"/>
+    <attribute attribute-name="seq.autoNaming" attribute-value="true"/>
 </sequence-manager>]]></source>
                     <p>
                         With property
-                        <code>grabSize</code> you set the size of the assigned
ID's kept
+                        <code>seq.grabSize</code> you set the size of the assigned
ID's kept
                         in memory for each <em>autoincrement</em> field. If the
assigned ID's
                         are exhausted a database call is made to lookup the next bunch
-                        of ID's using the next database sequence (default <em>grabSize</em>
is 20).
+                        of ID's using the next database sequence (default <em>seq.grabSize</em>
is 20).
                         <br/>
                         If OJB was shutdown/redeployed all unused assigned ID's are lost.
                     </p>
@@ -617,7 +689,7 @@
                     </note>
                     <p>
                         Attribute
-                        <a href="#auto-naming"><em>autoNaming</em></a>
+                        <a href="#auto-naming"><em>seq.autoNaming</em></a>
                         is the same as for <a href="#database-sequences-based">SequenceManagerNextValImpl</a>.
                     </p>
                     <p>
@@ -626,7 +698,7 @@
                         to manage the sequences (see
                         <a href="#sequence-name">more</a>) or if not
                         set in <code>field-descriptor</code> it is done automatic
when
-                        <a href="#auto-naming">autoNaming</a> is enabled.
+                        <a href="#auto-naming">seq.autoNaming</a> is enabled.
                     </p>
                     <p>
                         Limitations:
@@ -661,14 +733,16 @@
                         work with database <em>Identity columns</em>.
                     </p>
                     <p>
-                        To enable this sequence manager implementation set in your
-                        <code>jdbc-connection-descriptor</code>:
+                        To enable this <em>sequence manager</em> implementation
specify a <code>sequence-manager</code>
+                        element within the
+                        <a href="site:repository/jdbc-connection-descriptor">jdbc-connection-descriptor</a>
or
+                        <a href="site:repository/field-descriptor">field-descriptor</a>
+                        (<a href="#per-field-sequence">since OJB 1.0.5</a>) and
specifiy
+                        the <em>full class name</em> or the shortcut name (since
OJB 1.0.5) <em>identity</em>:
                     </p>
                     <source><![CDATA[
-<sequence-manager
-    className="org.apache.ojb.broker.util.sequence.SequenceManagerNativeImpl">
-</sequence-manager>
-                        ]]></source>
+<!--<sequence-manager className="org.apache.ojb.broker.util.sequence.SequenceManagerIdentityImpl"/>-->
+<sequence-manager className="identity"/>]]></source>
                     <p>
                         To declare the identity column in the persistent class mapping
                         <a href="site:repository/class-descriptor">class-descriptor</a>,
add the
@@ -690,8 +764,7 @@
         jdbc-type="BIGINT"
         primarykey="true"
         autoincrement="true"
-        access="readonly"/>
-                        ]]></source>
+        access="readonly"/>]]></source>
                     <p>
                         Limitations:
                         <br/>- The Identity columns have to
@@ -722,23 +795,28 @@
                         <em>Oracle-style</em> for all databases (e.g. MSSQL,
MySQL, DB2, ...).
                     </p>
                     <p>
-                        To declare this <em>sequence manager</em> implementation
specify a
-                        <code>sequence-manager</code> element within the
-                        <a href="site:repository/jdbc-connection-descriptor">jdbc-connection-descriptor</a>:
+                        To enable this <em>sequence manager</em> implementation
specify a <code>sequence-manager</code>
+                        element within the
+                        <a href="site:repository/jdbc-connection-descriptor">jdbc-connection-descriptor</a>
or
+                        <a href="site:repository/field-descriptor">field-descriptor</a>
+                        (<a href="#per-field-sequence">since OJB 1.0.5</a>) and
specifiy
+                        the <em>full class name</em> or the shortcut name (since
OJB 1.0.5) <em>procedure</em>:
                     </p>
                     <source><![CDATA[
-<sequence-manager className="org.apache.ojb.broker.util.sequence.SequenceManagerStoredProcedureImpl">
-    <attribute attribute-name="autoNaming" attribute-value="true"/>
+<!--<sequence-manager
+className="org.apache.ojb.broker.util.sequence.SequenceManagerStoredProcedureImpl">-->
+<sequence-manager className="procedure">
+    <attribute attribute-name="seq.autoNaming" attribute-value="true"/>
 </sequence-manager>]]></source>
                     <p>
-                        For attribute <a href="#auto-naming"><em>autoNaming</em>
see</a>.
+                        For attribute <a href="#auto-naming"><em>seq.autoNaming</em>
see</a>.
                     </p>
                     <p>
                         This sequence manager implementation supports user defined
                         <a href="#sequence-name"><em>sequence-names</em></a>
                         to manage the sequences or if not
                         set in <code>field-descriptor</code> it is done automatic
when
-                        <a href="#auto-naming">autoNaming</a> is enabled.
+                        <a href="#auto-naming">seq.autoNaming</a> is enabled.
                     </p>
                     <ul>
                         <li>
@@ -764,6 +842,45 @@
                             <th>Stored Procedure</th>
                         </tr>
                         <tr>
+                            <td>MySQL</td>
+                            <td>
+                                Create the table "OJB_NEXTVAL_SEQ":
+                                <source><![CDATA[
+DROP TABLE IF EXISTS OJB_NEXTVAL_SEQ;
+CREATE TABLE OJB_NEXTVAL_SEQ
+(
+    SEQ_NAME VARCHAR(150) NOT NULL,
+    MAX_KEY INTEGER,
+    PRIMARY KEY(SEQ_NAME)
+);]]></source>
+                            </td>
+                            <td>
+                                Create the procedure "ojb_nextval_proc"
+                                (It does not work with a function):
+                                <source><![CDATA[
+DROP PROCEDURE IF EXISTS OJB_NEXTVAL_PROC;
+
+delimiter //
+
+CREATE PROCEDURE ojb_nextval_proc(
+OUT MAX_KEY_PARAM INT,
+IN SEQ_NAME_PARAM VARCHAR(150))
+DETERMINISTIC
+BEGIN
+    UPDATE OJB_NEXTVAL_SEQ
+    SET MAX_KEY = MAX_KEY + 1
+    WHERE SEQ_NAME = SEQ_NAME_PARAM;
+
+    SELECT MAX_KEY INTO MAX_KEY_PARAM
+    FROM OJB_NEXTVAL_SEQ
+    WHERE SEQ_NAME = SEQ_NAME_PARAM;
+END;
+//
+
+delimiter ;]]></source>
+                            </td>
+                        </tr>
+                        <tr>
                             <td>MSSQL</td>
                             <td>
                                 <source><![CDATA[
@@ -801,8 +918,7 @@
 else
    select @MAX_KEY
 
-RETURN @MAX_KEY
-                                ]]></source>
+RETURN @MAX_KEY]]></source>
                             </td>
                         </tr>
                         <tr>
@@ -882,13 +998,17 @@
                     </p>
 
                     <p>
-                        You also need to turn on the SequenceManager in your
-                        jdbc-connection-descriptor like this:
+                        To enable this <em>sequence manager</em> implementation
specify a <code>sequence-manager</code>
+                        element within the
+                        <a href="site:repository/jdbc-connection-descriptor">jdbc-connection-descriptor</a>
or
+                        <a href="site:repository/field-descriptor">field-descriptor</a>
+                        (<a href="#per-field-sequence">since OJB 1.0.5</a>) and
specifiy
+                        the <em>full class name</em> or the shortcut name (since
OJB 1.0.5) <em>msguid</em>:
                     </p>
                     <source><![CDATA[
-<sequence-manager className="org.apache.ojb.broker.util.sequence.SequenceManagerMSSQLGuidImpl"
-/>
-                        ]]></source>
+<!--<sequence-manager
+className="org.apache.ojb.broker.util.sequence.SequenceManagerMSSQLGuidImpl"/>-->
+<sequence-manager className="msguid"/>]]></source>
                     <p>
                         Limitations:
                         <br/>-This will only work with SQL Server 7.0 and higher as
the
@@ -944,7 +1064,7 @@
                 </note>
                 <p>
                     If you don't specify a sequence name in the <em>field-descriptor</em>
it is possible
-                    to auto-assign a sequence-name by OJB if <a href="#auto-naming">autoNaming</a>
+                    to auto-assign a sequence-name by OJB if <a href="#auto-naming">seq.autoNaming</a>
                     is supported by the used sequence manager implementation.
                 </p>
 
@@ -952,17 +1072,17 @@
 
             <anchor id="auto-naming"/>
             <section>
-                <title>The <em>autoNaming</em> property</title>
+                <title>The <em>seq.autoNaming</em> property</title>
                 <p>
                     All shipped <a href="ext:sequence-manager">SequenceManager</a>
implementations
                     using <em>sequences</em> for ID generation support a property
-                    called <em>autoNaming</em> which can be declared as a
+                    called <em>seq.autoNaming</em> which can be declared as a
                     <a href="site:repository/custom-attribute"><em>custom attribute</em></a>
                     within the <em>sequence-manager</em> element:
                 </p>
                 <source><![CDATA[
 <sequence-manager className="org.apache.ojb.broker.util.sequence.SequenceManagerNextValImpl">
-<attribute attribute-name="autoNaming" attribute-value="true"/>
+<attribute attribute-name="seq.autoNaming" attribute-value="true"/>
 </sequence-manager>]]></source>
                 <p>
                     If set <em>true</em> OJB try to build a
@@ -979,7 +1099,7 @@
                     <em>field-descriptor</em> of the autoincrement field.
                     In this case OJB expects a valid <em>sequence-name</em> in
the <em>field-descriptor</em>.
                     <br/>
-                    If the attribute <code>autoNaming</code> is set <em>false</em>
the sequence manager
+                    If the attribute <code>seq.autoNaming</code> is set <em>false</em>
the sequence manager
                     never try to auto-generate a <em>sequence-name</em> (more
detailed info
                     <a href="#no-auto-build">here</a>). If set <em>true</em>
and a <em>sequence-name</em>
                     is set in the <em>field-descriptor</em>, the <em>SequenceManager</em>
will use this one and
@@ -1114,12 +1234,12 @@
                     <p>
                         All shipped
                         <code>SequenceManager</code> implementations which using
sequence names
-                        for UID generation, support by default auto-build (autoNaming) of
the sequence name
+                        for UID generation, support by default auto-build (seq.autoNaming)
of the sequence name
                         if none was found in the
                         <code>field-descriptor</code>.
                         <br/>
                         To prevent this, all relevant SM implementations support a
-                        <code>autoNaming</code>
+                        <code>seq.autoNaming</code>
                         property - set via
                         <code>attribute</code> element. If set
                         <code>false</code> OJB doesn't
@@ -1127,7 +1247,7 @@
                         </p>
 <source><![CDATA[
 <sequence-manager className="org.apache.ojb.broker.util.sequence.SequenceManagerNextValImpl">
-    <attribute attribute-name="autoNaming" attribute-value="false"/>
+    <attribute attribute-name="seq.autoNaming" attribute-value="false"/>
 </sequence-manager>]]></source>
                     <p>
                         Keep in mind that user defined sequence names have to be
@@ -1195,7 +1315,7 @@
                         <li>
                             When using <em>sequences</em> based sequence manager
implementations it's possible
                             to enable auto-generation of <em>sequence names</em>
- see
-                            <a href="#auto-naming">autoNaming section</a>.
+                            <a href="#auto-naming">auto naming section</a>.
                             To build the <em>sequence name</em> an simple algorithm
was used.
                             <br/>
                             <br/>



---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


Mime
View raw message