You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ofbiz.apache.org by Prashant Punekar <Pr...@mindtree.com> on 2009/10/24 07:40:23 UTC

auto increment !

Hi,

I am using mysql version 5.1.23 database.

The requirement is:

I have an entity defined in entity model -
<entity entity-name="nsInventoryAutoIncrement">
      <description>This entity stores the unique auto increment value starting from 3 trillion</description>
      <field name="inventorySeqId" type="numeric">
          <description>Inventory Sequence Id</description>
      </field>
      <field name="orderItemSeq" type="short-varchar">
          <description>This store orderId_OrderItemSeqId</description>
      </field>
       <prim-key field="inventorySeqId"/>
     </entity>


I would like to initialize the value of id column - inventorySeqId to say "30000000".
So when I do delegator.getNextSeqIdLong("nsInventoryAutoIncrement"), I should get 30000001.

First all I couldn't set the default value to 3000000.
So I added a dummy record with id as 3000000 expecting that the next seq method should return me 3000001 but its still returning me 10001 onwards. It seems that the auto increment default value for all entities is set to 10000.
How do I change it for one entity?

Regards,
Prashant

________________________________
http://www.mindtree.com/email/disclaimer.html

Re: auto increment !

Posted by Scott Gray <sc...@hotwaxmedia.com>.
All sequences are handled by the SequenceValueItem table, you do not  
need to define your own table to store sequences.  The name of the  
entity is stored in the seqName field and the seqId field will contain  
the starting id of the next bank of ids available.

If you want a particular entity to start with a higher id then you can  
seed the SequenceValueItem table with that id using seed-initial  
entity xml data:
Create an entity-xml file:
<?xml version="1.0" encoding="UTF-8"?>
<entity-engine-xml>
<SequenceValueItem seqName="InventoryItem" seqId="30000000"/>
</entity-engine-xml/>

Then reference the xml file in your component's ofbiz-component.xml  
file:
<entity-resource type="data" reader-name="seed-initial" loader="main"  
location="data/MyCustomSeqIdsData.xml"/>

Assuming that you are loading seed + your custom data only on a fresh  
database just run "ant run-install-extseed".
If you don't want to clear your database then just load the data via  
webtools and then restart to clear the current bank of ids.

Regards
Scott

HotWax Media
http://www.hotwaxmedia.com

On 24/10/2009, at 7:33 PM, Vivek Mishra wrote:

> Hi Prashant,
>
> We have an attribute named "sequence-bank-size" in entity tag of  
> entitymodel.xml file. Set its value to 1 so that it will increment  
> the sequence by 1.
>
> Refer SequenceUtil.java file, here you have startSeqId variable in  
> SequenceBank class. As you have customize need to start sequence  
> with 30000000 so just patch this value for startSeqId.
>
> This may be the solution of your problem but I wonder don't we have  
> any configuration available in OFBiz for doing this or it needs  
> implementation?
>
> Thoughts are most welcome.
>
> Thanks and Regards,
> -- Vivek Mishra
>
> Prashant Punekar wrote:
>>
>> Hi,
>>
>> I am using mysql version 5.1.23 database.
>>
>> The requirement is:
>>
>> I have an entity defined in entity model -
>> <entity entity-name="nsInventoryAutoIncrement">
>>       <description>This entity stores the unique auto increment  
>> value starting from 3 trillion</description>
>>       <field name="inventorySeqId" type="numeric">
>>           <description>Inventory Sequence Id</description>
>>       </field>
>>       <field name="orderItemSeq" type="short-varchar">
>>           <description>This store orderId_OrderItemSeqId</ 
>> description>
>>       </field>
>>        <prim-key field="inventorySeqId"/>
>>      </entity>
>>
>>
>> I would like to initialize the value of id column - inventorySeqId  
>> to say "30000000".
>> So when I do  
>> delegator.getNextSeqIdLong("nsInventoryAutoIncrement"), I should  
>> get 30000001.
>>
>> First all I couldn't set the default value to 3000000.
>> So I added a dummy record with id as 3000000 expecting that the  
>> next seq method should return me 3000001 but its still returning me  
>> 10001 onwards. It seems that the auto increment default value for  
>> all entities is set to 10000.
>> How do I change it for one entity?
>>
>> Regards,
>> Prashant
>>
>> ________________________________
>> http://www.mindtree.com/email/disclaimer.html
>>
>>


Re: auto increment !

Posted by Vivek Mishra <vi...@hotwaxmedia.com>.
Hi Prashant,

We have an attribute named *"sequence-bank-size" *in entity tag of 
entitymodel.xml file. Set its value to 1 so that it will increment the 
sequence by 1.

Refer SequenceUtil.java file, here you have *startSeqId *variable in 
SequenceBank class. As you have customize need to start sequence with 
30000000 so just patch this value for *startSeqId*.

This may be the solution of your problem but I wonder don't we have any 
configuration available in OFBiz for doing this or it needs implementation?

Thoughts are most welcome.

Thanks and Regards,
-- Vivek Mishra
*
*Prashant Punekar wrote:
> Hi,
>
> I am using mysql version 5.1.23 database.
>
> The requirement is:
>
> I have an entity defined in entity model -
> <entity entity-name="nsInventoryAutoIncrement">
>       <description>This entity stores the unique auto increment value starting from 3 trillion</description>
>       <field name="inventorySeqId" type="numeric">
>           <description>Inventory Sequence Id</description>
>       </field>
>       <field name="orderItemSeq" type="short-varchar">
>           <description>This store orderId_OrderItemSeqId</description>
>       </field>
>        <prim-key field="inventorySeqId"/>
>      </entity>
>
>
> I would like to initialize the value of id column - inventorySeqId to say "30000000".
> So when I do delegator.getNextSeqIdLong("nsInventoryAutoIncrement"), I should get 30000001.
>
> First all I couldn't set the default value to 3000000.
> So I added a dummy record with id as 3000000 expecting that the next seq method should return me 3000001 but its still returning me 10001 onwards. It seems that the auto increment default value for all entities is set to 10000.
> How do I change it for one entity?
>
> Regards,
> Prashant
>
> ________________________________
> http://www.mindtree.com/email/disclaimer.html
>
>