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 Längerich, Bernd <B....@actosoft.de> on 2007/01/30 14:33:30 UTC

SequenceManagerHighLowImpl

Hi,

I have some problems with OJB (PB-API) and the sequence manager. I derived a new sequence manager from the shipped HighLowImpl, that checks for every grab size with SequenceManagerHelper.getMaxForExtent() for the max id of the field. This works fine with data added externally, but I have a situation where the original HighLowImpl and my version fails:

Given the scenario, where the application has created an instance of the sequence manager for the PK field and inserts some data with fixed field contents from another source, with a pk field contents of any value in the current range of prefetched ids (grabsize), I get a dup key constraints error when the sequence manager reaches these rows.

The background is, that we store each row to a primary data base and a backup data base. Whenever the computer with the primary data base crashes, it can be restored from an automatic backup, but this will be up to several hours old, so we recover the missing data from the backup data base and store them to the primary db (using OJB PB-Api). 

Is there any way of forcing the sequence manager to be recreated? At the moment I have a workaround with fetching grabSize ids with
Identity oid = broker.serviceIdentity().buildIdentity(Object newPersistentObject);

Is it sufficient/possible to overwrite the afterStore() method of the sequence manager?

Best regards
Bernd


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


Re: SequenceManagerHighLowImpl

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

Längerich wrote:
> Hi,
> 
> I have some problems with OJB (PB-API) and the sequence manager. I
> derived a new sequence manager from the shipped HighLowImpl, that
> checks for every grab size with
> SequenceManagerHelper.getMaxForExtent() for the max id of the field.
> This works fine with data added externally, but I have a situation
> where the original HighLowImpl and my version fails:
> 
> Given the scenario, where the application has created an instance of
> the sequence manager for the PK field and inserts some data with
> fixed field contents from another source, with a pk field contents of
> any value in the current range of prefetched ids (grabsize), I get a
> dup key constraints error when the sequence manager reaches these
> rows.
> 
> The background is, that we store each row to a primary data base and
> a backup data base. Whenever the computer with the primary data base
> crashes, it can be restored from an automatic backup, but this will
> be up to several hours old, so we recover the missing data from the
> backup data base and store them to the primary db (using OJB PB-Api).
> 
> 
> Is there any way of forcing the sequence manager to be recreated? At
> the moment I have a workaround with fetching grabSize ids with 
> Identity oid = broker.serviceIdentity().buildIdentity(Object
> newPersistentObject);
> 
> Is it sufficient/possible to overwrite the afterStore() method of the
> sequence manager?

Yep it's possible. Assume you want to lookup the HLSequence-object for 
the current used (fixed) field and invalidate the current used PK value 
or declare that the next sequence value has to greater than this to 
avoid duplicate PK values. Think this should work (except if an 
concurrent thread request the next value before the current thread can 
invalidate it).

regards,
Armin

> 
> Best regards Bernd
> 
> 
> ---------------------------------------------------------------------
>  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