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/test/org/apache/ojb repository_database.xml
Date Mon, 22 Aug 2005 15:27:29 GMT
arminw      2005/08/22 08:27:29

  Modified:    src/doc/forrest/src/documentation/content/xdocs/docu/guides
                        Tag: OJB_1_0_RELEASE sequencemanager.xml
               src/java/org/apache/ojb/broker/platforms Tag:
                        OJB_1_0_RELEASE PlatformDb2Impl.java
               src/java/org/apache/ojb/broker/util/sequence Tag:
                        OJB_1_0_RELEASE SequenceManager.java
                        SequenceManagerHelper.java
               src/test/org/apache/ojb Tag: OJB_1_0_RELEASE
                        repository_database.xml
  Log:
  add additional database sequence creation property, update DB2 sequence creation, move database
sequence creation property constants from SequenceManager to ...Helper.java
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.1.2.5   +11 -1     db-ojb/src/doc/forrest/src/documentation/content/xdocs/docu/guides/sequencemanager.xml
  
  Index: sequencemanager.xml
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/doc/forrest/src/documentation/content/xdocs/docu/guides/sequencemanager.xml,v
  retrieving revision 1.1.2.4
  retrieving revision 1.1.2.5
  diff -u -r1.1.2.4 -r1.1.2.5
  --- sequencemanager.xml	16 Aug 2005 20:11:19 -0000	1.1.2.4
  +++ sequencemanager.xml	22 Aug 2005 15:27:28 -0000	1.1.2.5
  @@ -416,6 +416,16 @@
                               <th>Supported By</th>
                           </tr>
                           <tr>
  +                            <td>seq.as</td>
  +                            <td>database specific, e.g. <em>INTEGER</em></td>
  +                            <td>
  +                            Database sequence specific property.<br/>
  +                            Specifies the datatype of the sequence, the allowed datatypes
  +                            depend on the used database implementation.
  +                            </td>
  +                            <td>DB2</td>
  +                        </tr>
  +                        <tr>
                               <td>seq.start</td>
                               <td>1 ... max INTEGER</td>
                               <td>
  
  
  
  No                   revision
  No                   revision
  1.10.2.2  +52 -8     db-ojb/src/java/org/apache/ojb/broker/platforms/PlatformDb2Impl.java
  
  Index: PlatformDb2Impl.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/platforms/PlatformDb2Impl.java,v
  retrieving revision 1.10.2.1
  retrieving revision 1.10.2.2
  diff -u -r1.10.2.1 -r1.10.2.2
  --- PlatformDb2Impl.java	16 Aug 2005 20:11:19 -0000	1.10.2.1
  +++ PlatformDb2Impl.java	22 Aug 2005 15:27:28 -0000	1.10.2.2
  @@ -34,7 +34,7 @@
    * for detailed description.
    *
    * <p>
  - * Implementation configuration properties:
  + * Supported properties on sequence creation:
    * </p>
    *
    * <table cellspacing="2" cellpadding="2" border="3" frame="box">
  @@ -43,6 +43,14 @@
    *     <td><strong>Property Values</strong></td>
    * </tr>
    * <tr>
  + *     <td>seq.as</td>
  + *     <td>
  + *          Database sequence specific property.<br/>
  + *          Specifies the datatype used for the sequence.
  + *          Allowed: all numeric datatypes? e.g. <em>INTEGER</em>
  + *    </td>
  + * </tr>
  + * <tr>
    *     <td>sequenceStart</td>
    *     <td>
    *          DEPRECATED. Database sequence specific property.<br/>
  @@ -143,16 +151,43 @@
   
       public String createSequenceQuery(String sequenceName, Properties prop)
       {
  +        /*
  +        Read syntax diagramSkip visual syntax diagram
  +                                              .-AS INTEGER----.
  +        >>-CREATE SEQUENCE--sequence-name--*--+---------------+--*------>
  +                                              '-AS--data-type-'
  +
  +        >--+------------------------------+--*-------------------------->
  +           '-START WITH--numeric-constant-'
  +
  +           .-INCREMENT BY 1-----------------.
  +        >--+--------------------------------+--*------------------------>
  +           '-INCREMENT BY--numeric-constant-'
  +
  +           .-NO MINVALUE----------------.
  +        >--+----------------------------+--*---------------------------->
  +           '-MINVALUE--numeric-constant-'
  +
  +           .-NO MAXVALUE----------------.     .-NO CYCLE-.
  +        >--+----------------------------+--*--+----------+--*----------->
  +           '-MAXVALUE--numeric-constant-'     '-CYCLE----'
  +
  +           .-CACHE 20----------------.     .-NO ORDER-.
  +        >--+-------------------------+--*--+----------+--*-------------><
  +           +-CACHE--integer-constant-+     '-ORDER----'
  +           '-NO CACHE----------------'
  +        */
           StringBuffer query = new StringBuffer(createSequenceQuery(sequenceName));
           if(prop != null)
           {
               Boolean b;
               Long value;
  +            String str;
   
  -            value = SequenceManagerHelper.getSeqIncrementBy(prop);
  -            if(value != null)
  +            str = SequenceManagerHelper.getSeqAsValue(prop);
  +            if(str != null)
               {
  -                query.append(" INCREMENT BY ").append(value.longValue());
  +                query.append(" AS ").append(str);
               }
   
               value = SequenceManagerHelper.getSeqStart(prop);
  @@ -161,10 +196,10 @@
                   query.append(" START WITH ").append(value.longValue());
               }
   
  -            value = SequenceManagerHelper.getSeqMaxValue(prop);
  +            value = SequenceManagerHelper.getSeqIncrementBy(prop);
               if(value != null)
               {
  -                query.append(" MAXVALUE ").append(value.longValue());
  +                query.append(" INCREMENT BY ").append(value.longValue());
               }
   
               value = SequenceManagerHelper.getSeqMinValue(prop);
  @@ -173,6 +208,12 @@
                   query.append(" MINVALUE ").append(value.longValue());
               }
   
  +            value = SequenceManagerHelper.getSeqMaxValue(prop);
  +            if(value != null)
  +            {
  +                query.append(" MAXVALUE ").append(value.longValue());
  +            }
  +
               b = SequenceManagerHelper.getSeqCycleValue(prop);
               if(b != null)
               {
  @@ -210,8 +251,11 @@
       {
           // matthias.roth@impart.ch
           // the function is used by the org.apache.ojb.broker.util.sequence.SequenceManagerNativeImpl
  -        // this call must be made before commit the insert cammand, so you
  +		// this call must be made before commit the insert command, so you
           // must turn off autocommit by seting the useAutoCommit="2"
  +        // or use useAutoCommit="1" or use a connection with autoCommit set false
  +        // by default (e.g. in managed environments)
  +        // transaction demarcation is mandatory
           return "select IDENTITY_VAL_LOCAL() from sysibm.sysdummy1";
       }
   }
  
  
  
  No                   revision
  No                   revision
  1.10.2.5  +1 -36     db-ojb/src/java/org/apache/ojb/broker/util/sequence/SequenceManager.java
  
  Index: SequenceManager.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/util/sequence/SequenceManager.java,v
  retrieving revision 1.10.2.4
  retrieving revision 1.10.2.5
  diff -u -r1.10.2.4 -r1.10.2.5
  --- SequenceManager.java	16 Aug 2005 20:11:19 -0000	1.10.2.4
  +++ SequenceManager.java	22 Aug 2005 15:27:29 -0000	1.10.2.5
  @@ -40,41 +40,6 @@
   public interface SequenceManager
   {
       /**
  -     * Property name used to configure sequence manager implementations.
  -     * @deprecated use {@link #PROP_SEQ_START} instead.
  -     */
  -    public static final String PROP_SEQ_START_OLD = "sequenceStart";
  -    /**
  -     * Property name used to configure sequence manager implementations.
  -     */
  -    public static final String PROP_SEQ_START = "seq.start";
  -    /**
  -     * Property name used to configure sequence manager implementations.
  -     */
  -    public static final String PROP_SEQ_INCREMENT_BY = "seq.incrementBy";
  -    /**
  -     * Property name used to configure sequence manager implementations.
  -     */
  -    public static final String PROP_SEQ_MAX_VALUE = "seq.maxValue";
  -    /**
  -     * Property name used to configure sequence manager implementations.
  -     */
  -    public static final String PROP_SEQ_MIN_VALUE = "seq.minValue";
  -    /**
  -     * Property name used to configure sequence manager implementations.
  -     */
  -    public static final String PROP_SEQ_CYCLE = "seq.cycle";
  -    /**
  -     * Property name used to configure sequence manager implementations.
  -     */
  -    public static final String PROP_SEQ_CACHE = "seq.cache";
  -    /**
  -     * Property name used to configure sequence manager implementations.
  -     */
  -    public static final String PROP_SEQ_ORDER = "seq.order";
  -
  -
  -    /**
        * This method is called to get an unique value <strong>before</strong>
the object
        * is written to persistent storage.
        * <br/>
  
  
  
  1.17.2.5  +63 -17    db-ojb/src/java/org/apache/ojb/broker/util/sequence/SequenceManagerHelper.java
  
  Index: SequenceManagerHelper.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/util/sequence/SequenceManagerHelper.java,v
  retrieving revision 1.17.2.4
  retrieving revision 1.17.2.5
  diff -u -r1.17.2.4 -r1.17.2.5
  --- SequenceManagerHelper.java	16 Aug 2005 20:11:19 -0000	1.17.2.4
  +++ SequenceManagerHelper.java	22 Aug 2005 15:27:29 -0000	1.17.2.5
  @@ -41,6 +41,44 @@
   {
       private static Logger log = LoggerFactory.getLogger(SequenceManagerHelper.class);
   
  +    /**
  +     * Property name used to configure sequence manager implementations.
  +     */
  +    public static final String PROP_SEQ_AS = "seq.as";
  +    /**
  +     * Property name used to configure sequence manager implementations.
  +     * @deprecated use {@link #PROP_SEQ_START} instead.
  +     */
  +    public static final String PROP_SEQ_START_OLD = "sequenceStart";
  +    /**
  +     * Property name used to configure sequence manager implementations.
  +     */
  +    public static final String PROP_SEQ_START = "seq.start";
  +    /**
  +     * Property name used to configure sequence manager implementations.
  +     */
  +    public static final String PROP_SEQ_INCREMENT_BY = "seq.incrementBy";
  +    /**
  +     * Property name used to configure sequence manager implementations.
  +     */
  +    public static final String PROP_SEQ_MAX_VALUE = "seq.maxValue";
  +    /**
  +     * Property name used to configure sequence manager implementations.
  +     */
  +    public static final String PROP_SEQ_MIN_VALUE = "seq.minValue";
  +    /**
  +     * Property name used to configure sequence manager implementations.
  +     */
  +    public static final String PROP_SEQ_CYCLE = "seq.cycle";
  +    /**
  +     * Property name used to configure sequence manager implementations.
  +     */
  +    public static final String PROP_SEQ_CACHE = "seq.cache";
  +    /**
  +     * Property name used to configure sequence manager implementations.
  +     */
  +    public static final String PROP_SEQ_ORDER = "seq.order";
  +
       private static final String SEQ_PREFIX = "SEQ_";
       private static final String SEQ_UNASSIGNED = "UNASSIGNED";
       private static final String SM_SELECT_MAX = "SELECT MAX(";
  @@ -150,15 +188,12 @@
           }
   //        System.out.println("* targetClass: " + cldTargetClass.getClassNameOfObject()
+ ", toplevel: " + topLevel + " seqName: " + seqName);
           seqName = SEQ_PREFIX + seqName;
  -        if (autoNaming)
  -        {
  -            if (log.isDebugEnabled())
  +        if (log.isDebugEnabled())
                   log.debug("Set automatic generated sequence-name for field '" +
                           field.getAttributeName() + "' in class '" +
                           field.getClassDescriptor().getClassNameOfObject() +
                           "'.");
  -            field.setSequenceName(seqName);
  -        }
  +        field.setSequenceName(seqName);
           return seqName;
       }
   
  @@ -230,7 +265,7 @@
       public static long getMaxId(PersistenceBroker brokerForClass, Class topLevel, FieldDescriptor
original) throws PersistenceBrokerException
       {
           long max = 0;
  -        long tmp = 0;
  +        long tmp;
           ClassDescriptor cld = brokerForClass.getClassDescriptor(topLevel);
   
           // if class is not an interface / not abstract we have to search its directly mapped
table
  @@ -240,7 +275,6 @@
               if (tmp > max)
               {
                   max = tmp;
  -                tmp = 0;
               }
           }
           // if class is an extent we have to search through its subclasses
  @@ -264,7 +298,6 @@
                   if (tmp > max)
                   {
                       max = tmp;
  -                    tmp = 0;
                   }
               }
           }
  @@ -346,10 +379,10 @@
        */
       public static Long getSeqStart(Properties prop)
       {
  -        String result = prop.getProperty(SequenceManager.PROP_SEQ_START, null);
  +        String result = prop.getProperty(PROP_SEQ_START, null);
           if(result == null)
           {
  -            result = prop.getProperty(SequenceManager.PROP_SEQ_START_OLD, null);
  +            result = prop.getProperty(PROP_SEQ_START_OLD, null);
           }
           if(result != null)
           {
  @@ -371,7 +404,7 @@
        */
       public static Long getSeqIncrementBy(Properties prop)
       {
  -        String result = prop.getProperty(SequenceManager.PROP_SEQ_INCREMENT_BY, null);
  +        String result = prop.getProperty(PROP_SEQ_INCREMENT_BY, null);
           if(result != null)
           {
               return new Long(Long.parseLong(result));
  @@ -392,7 +425,7 @@
        */
       public static Long getSeqMaxValue(Properties prop)
       {
  -        String result = prop.getProperty(SequenceManager.PROP_SEQ_MAX_VALUE, null);
  +        String result = prop.getProperty(PROP_SEQ_MAX_VALUE, null);
           if(result != null)
           {
               return new Long(Long.parseLong(result));
  @@ -413,7 +446,7 @@
        */
       public static Long getSeqMinValue(Properties prop)
       {
  -        String result = prop.getProperty(SequenceManager.PROP_SEQ_MIN_VALUE, null);
  +        String result = prop.getProperty(PROP_SEQ_MIN_VALUE, null);
           if(result != null)
           {
               return new Long(Long.parseLong(result));
  @@ -434,7 +467,7 @@
        */
       public static Long getSeqCacheValue(Properties prop)
       {
  -        String result = prop.getProperty(SequenceManager.PROP_SEQ_CACHE, null);
  +        String result = prop.getProperty(PROP_SEQ_CACHE, null);
           if(result != null)
           {
               return new Long(Long.parseLong(result));
  @@ -455,7 +488,7 @@
        */
       public static Boolean getSeqCycleValue(Properties prop)
       {
  -        String result = prop.getProperty(SequenceManager.PROP_SEQ_CYCLE, null);
  +        String result = prop.getProperty(PROP_SEQ_CYCLE, null);
           if(result != null)
           {
               return Boolean.getBoolean(result) ? Boolean.TRUE : Boolean.FALSE;
  @@ -476,7 +509,7 @@
        */
       public static Boolean getSeqOrderValue(Properties prop)
       {
  -        String result = prop.getProperty(SequenceManager.PROP_SEQ_ORDER, null);
  +        String result = prop.getProperty(PROP_SEQ_ORDER, null);
           if(result != null)
           {
               return Boolean.getBoolean(result) ? Boolean.TRUE : Boolean.FALSE;
  @@ -486,4 +519,17 @@
               return null;
           }
       }
  +
  +    /**
  +     * Database sequence properties helper method.
  +     * Return the datatype to set for the sequence or <em>null</em>
  +     * if not set.
  +     *
  +     * @param prop The {@link java.util.Properties} instance to use.
  +     * @return The found expression or <em>null</em>.
  +     */
  +    public static String getSeqAsValue(Properties prop)
  +    {
  +        return prop.getProperty(PROP_SEQ_AS, null);
  +    }
   }
  
  
  
  No                   revision
  No                   revision
  1.22.2.14 +5 -3      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.22.2.13
  retrieving revision 1.22.2.14
  diff -u -r1.22.2.13 -r1.22.2.14
  --- repository_database.xml	16 Aug 2005 20:14:39 -0000	1.22.2.13
  +++ repository_database.xml	22 Aug 2005 15:27:29 -0000	1.22.2.14
  @@ -120,8 +120,10 @@
               please see "Sequence Manager" guide or/and javadoc of classes for more information
-->
               <attribute attribute-name="grabSize" attribute-value="20"/>
   
  -            <!-- optional attributes supported by SequenceManagerNextValImpl, please
  -            see "Sequence Manager" guide or/and javadoc of classes for more information
-->
  +            <!-- optional attributes supported by SequenceManagerNextValImpl (support
depends
  +            on the used database), please see "Sequence Manager" guide or/and javadoc of
  +            classes for more information -->
  +            <!-- attribute attribute-name="seq.as" attribute-value="INTEGER"/ -->
               <!-- attribute attribute-name="seq.incrementBy" attribute-value="1"/ -->
               <!-- attribute attribute-name="seq.maxValue" attribute-value="999999999999999999999999999"/
-->
               <!-- attribute attribute-name="seq.minValue" attribute-value="1"/ -->
  
  
  

---------------------------------------------------------------------
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