I am trying to use the following approach to get a unique sequence value without actually persisting an object into the table associated with the sequence. (I really only want the unique sequence of values. I.e. if the DB provided an Oracle style sequence, I'd probably just do a SQL nextval() call on it.). I guess I'm attempting to construct a psuedo-sequence of sorts with a one-column table that I never insert into, but has an OJB HL sequence associated with it.

I'm using the approach as given in the OJB Documentation here:

======================================================================
http://db.apache.org/ojb/docu/guides/sequencemanager.html#Force+computation+of+unique+values

Identity oid = broker.serviceIdentity().buildIdentity(Object newPersistentObject);
=======================================================================
(The persistent object that I'm providing is an instance of OccHeadingGroupSequenceVO which is given in the repository class-descriptor below.)

For a single junit test run, I am seeing a sequence of unique values. However, between runs, I'm seeing the same exact sequence - i.e. it has the same starting value! I'm not seeing the OBJ_HL_SEQ table being updated as expected either.

I'm using the following sequence manager:
org.apache.ojb.broker.util.sequence.SequenceManagerHighLowImpl


I am seeing the exact same behavour with both MySQL and HSQL.

Is this correct behavour and I'm just misusing the buildIdentity() call? Or am I missing something else?

Here is my repository class-descriptor:
===========================================================
    <class-descriptor
        class="OccHeadingGroupSequenceVO"
        table="occ_heading_group_sequence"
    >
<!-- Primary Key $DEFAULT(pk,SEQ:occ_heading_group_sequence_seq) -->
       <field-descriptor
           id="1"
           name="pk"
           column="pk"
           jdbc-type="INTEGER"
           nullable="false"
           primarykey="true"
           autoincrement="true"
           sequence-name="occ_heading_group_sequence_seq"
       />
    </class-descriptor>
============================================================

Note that in a second test in which I actually do inserts into the occ_heading_group_sequence table, everything behaves as expected.

At this point I'm assuming that I may be missing something on a conceptual level and someone can help me out with the information I've given. If however, the devil is in the details, let me know and I'll go there.

Or, if someone has a better approach to what I'm wanting, I'm listening...

Thanks!
John



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to