Hi again, 

finally I used GenericDelegator.getNextSeqIdLong() when creating
entities. 

It does increment the sequence by 1. 

However today I noticed, that in the database - sequence_value_item
table  - the seq_id value gets incremented by 10. 

The reason is that the org.ofbiz.entity.util.SequenceUtil class creates
a SequenceBank with the default value ot 10 IDs. 

This is a MAJOR problem. It would appear if the server dies or gets a
hard restart for some reason ( or even JVM error ) - we'll end up with
gaps.  

I couldn't find any API that forces the SequenceUtil to create a
SequnenceBank sized to 1 . Is there a way to do it ?


Also: 

I couldn't find any info in the mail threads regarding this sequencing
mechanism being thread safe. 
Although I ran several threads requesting next ID from the same sequence
- and it works OK -  I am not quite convinced what would happen if we
have 2 ofbiz instances running against the same database. Is this setup
supported ?

Thanks in advance, 
Deyan 

On Sat, 2009-06-13 at 15:27 +0200, Jacques Le Roux wrote:
> This has been already dicussed many times. You may find information using 
> MarMail or Nable, some threads are even very detailled
> 
> Good luck
> 
> Jacques
> 
> From: "Deyan Tsvetanov" <[email protected]>
> > Exactly, I knew I've seen it somewhere :)
> > "Enforced Sequence (no gaps, per organization)"
> > 
> > Thanks guys, 
> > I'll have a look at it. 
> > 
> > Another question: do you have any idea how this enforced sequence might
> > behave in case of two ofbiz servers - in a cluster or sharing a
> > database ?
> > 
> > My goal is to generate IDs without absolutely any gaps. 
> > 
> > Another very important requirement is that the order of the record's
> > CREATED_DATE should match the order of the IDs. It is not possible to go
> > back and fill a gap. 
> > 
> > Example: 
> > 
> > A good example:
> >   ID          |           CREATED_DATE
> > ---------------------------------------------
> >    1          |            1 June  9:00 AM
> >    2          |            1 June 10:00 AM
> > 
> > A bad example:
> > 
> >   ID          |           CREATED_DATE
> > ---------------------------------------------
> >    1          |            1 June 10:00 AM
> >    2          |            1 June  9:00 AM
> > 
> > 
> > I already have an idea of a workaround, 
> > but I'll investigate the enforced sequence first. 
> > 
> > Thanks again, 
> > Deyan 
> > 
> > 
> > 
> > On Sat, 2009-06-13 at 05:42 -0700, BJ Freeman wrote:
> >> Organization GL Settings >Available Internal
> >> Organizations>Company>Setup>Accounting Preferences
> >> 
> >> David E Jones sent the following on 6/13/2009 5:15 AM:
> >> > 
> >> > Take a look at the party/organization accounting preferences in the
> >> > Accounting Manager. If you're looking for this sort of sequencing for
> >> > invoices, orders, etc then it is already supported.
> >> > 
> >> > -David
> >> > 
> >> > 
> >> > On Jun 13, 2009, at 5:44 AM, Deyan Tsvetanov wrote:
> >> > 
> >> >> Hi list,
> >> >>
> >> >> I'd like to use a custom ID generator - for instance rather to start
> >> >> from 10000 and increment by 10 I'd like to start from 0, increment by 1
> >> >> leaving no empty values and probably append some other rules - like to
> >> >> reset to 0 in the beginning of each year and prefix the returned ID by
> >> >> the current year.
> >> >>
> >> >> Example:
> >> >>
> >> >> 200900001
> >> >> 200900002
> >> >> ....
> >> >> 200932110
> >> >> ....
> >> >> 201000001    <--- a new year starts.
> >> >>
> >> >> I know it may sound pretty dumb, but the law makers in some countries
> >> >> are not so smart.
> >> >>
> >> >> So - could somebody give me some hints - is it possible to specify a
> >> >> custom ID generator per field typed "id-ne" in the entitymodel.xml ?
> >> >>
> >> >> Thanks in advance,
> >> >> Deyan
> >> >>
> >> > 
> >> > 
> >> 
> >
> 

Reply via email to