You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by JKramer <ja...@ascenditsolutions.com> on 2006/02/14 00:24:42 UTC

Problem SequenceManagerHighLowImpl and forcing unique, persistent, sequence values.

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: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: Problem SequenceManagerHighLowImpl and forcing unique, persistent, sequence values.

Posted by Armin Waibel <ar...@apache.org>.
Hi John,

sorry for the hassle. Between 1.0.3 and 1.0.4 we have to change Identity 
handling but I forget completely to update docs.

More details here
http://mail-archives.apache.org/mod_mbox/db-ojb-user/200602.mbox/%3c43F34494.8020303@apache.org%3e
or
http://www.mail-archive.com/ojb-user%40db.apache.org/msg14901.html

regards,
Armin


JKramer wrote:
> 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: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
> 
> 

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