Uploaded image for project: 'OJB'
  1. OJB
  2. OJB-66

Allow to specify a sequence start element for SequenceManagerNextValImpl

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.0.3
    • 1.0.4
    • None
    • Oracle 9i
      OJB 1.0.3
      JDK 1.4.2

    Description

      SequenceManagerNextValImpl doesn't support the globalSequenceStart attribute.
      Thus all sequences start at 1, even though we may have inserted some sample data already.
      Not being able to start at >1 means we'll have errors when inserting new elements when sample data was already inserted.

      I'd like to be able to write:

      <sequence-manager
      className="org.apache.ojb.broker.util.sequence.SequenceManagerNextValImpl">
      <attribute attribute-name="autoNaming" attribute-value="true"/>
      <attribute attribute-name="globalSequenceStart" attribute-value="1000"/>
      </sequence-manager>

      I also noticed that the PlatformOracleImpl can only create "simple" sequences, though it'd be great if this (and other platforms) support a method which could be used to specify the sequence start.

      So that'd be great if there could be another method than:
      public String createSequenceQuery(String sequenceName)

      For instance:
      public String createSequenceQuery(String sequenceName, int sequenceStart)

      On Oracle 9i, we can create a sequence like:
      CREATE SEQUENCE FOOBAR_SEQ;

      That's what currently supported by the standard createSequenceQuery method, but it's also possible to create a more complex sequence with:
      CREATE SEQUENCE FOOBAR_SEQ START WITH 41 MAXVALUE 999999999999999999999999999 MINVALUE 1 NOCYCLE CACHE 20 NOORDER;

      Or more simply:
      CREATE SEQUENCE FOOBAR_SEQ START WITH 41

      It may be interesting to be able to specify the other parameters as well, and we could probably reuse them when defining the sequence manager, with something like:

      <sequence-manager
      className="org.apache.ojb.broker.util.sequence.SequenceManagerNextValImpl">
      <attribute attribute-name="autoNaming" attribute-value="true"/>
      <attribute attribute-name="globalSequenceStart" attribute-value="1000"/>
      <attribute attribute-name="minValue" attribute-value="1000"/>
      <attribute attribute-name="maxValue" attribute-value="1000"/>
      <attribute attribute-name="noCycle"/>
      <attribute attribute-name="cache" attribute-value="20"/>
      <attribute attribute-name="noOrder"/>
      </sequence-manager>

      (cache 20 pre-computes 20 sequence ids and puts them in a cache, without requiring a new select)

      Attachments

        Activity

          People

            Unassigned Unassigned
            glaforge Guillaume Laforge
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: