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 Armin Waibel <ar...@code-au-lait.de> on 2003/12/02 22:57:21 UTC

Re: Problems using sequence-manger for MsSqlServer

Hi,

Rogerio Tambellini wrote:
> I'm using OJB connecting to MsSqlServer, but I'm not able to automatic 
> increment a column into the column. I've added the following line into 
> the repository.xml:
> 
> <sequence-manager
>     
> className="org.apache.ojb.broker.util.sequence.SequenceManagerHighLowImpl">
>    <attribute attribute-name="grabSize" attribute-value="1"/>
> </sequence-manager>
> 
please set grabSize > 1, because 1 will eliminate the advantage of this 
implementation (default was 20).
see http://db.apache.org/ojb/sequencemanager.html

> Primary key column in the table is set to Auto-Increment, but it's still 
> not working. When I store into the database, "store" operation always 
> updates the 0 id line.
> 
hmm, if your field-descriptor looks like

<field-descriptor
      name="articleId"
      column="ARTICLE_ID"
      jdbc-type="INTEGER"
      primarykey="true"
      autoincrement="true"
     />

all should work well.

regards,
Armin

> Please, anyone has a implentation sample or a tutorial for 
> OJB+MsSqlServer? Or just a hint?
> 
> Regards,
> Rogério
> 
> 
> ---------------------------------------------------------------------
> 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


Re: Problems using sequence-manger for MsSqlServer

Posted by Rogerio Tambellini <ro...@softtek.com>.
Hi,

I'm not able to create tables (OJB tables) and modify the column names, 
so I cannot use "SequenceManagerHighLowImpl", then I changed to 
"SequenceManagerNextValImpl" hopping it would work. Unfortunatlly, it's 
not working, but I discovery 1 problem, and I'd like to know how it 
would be handled.

If I call "store" method, OJB update 0 id, in fact, in the first time, 
when 0 id does not exists, it inserts, after that, always updates.

Id attribute is inicialized by 0 when my class is instanciated. How 
would I inform that 0 is not be updated, but always inserted instead in 
the next id value?

Regards,
Rogério

Armin Waibel wrote:

> Hi,
>
> Rogerio Tambellini wrote:
>
>> It still not working... :-(
>> Do I have to implement a store procedure and create OJB tables like 
>> OJB_NEXTVAL_SEQ?
>>
> SequenceManagerHighLowImpl use a DB table called OJB_HL_SEQ to manage 
> the keys, but this table is part of the repository_internal.xml, thus 
> you should generate it. More info about the OJB specific table can be 
> found here http://db.apache.org/ojb/platforms.html
>
> If you read the sequence manager doc
> http://db.apache.org/ojb/sequencemanager.html
> you can find other sequence manager implementations. One of this 
> implementations use stored procedure to manage keys.
>
> You can to to use *SequenceManagerInMemoryImpl* for your test. This 
> implementation doesn't need any database tables.
>
> Superfluous to say, do not define column "CdEmp" as Identity column 
> (to use Identity columns you have to use SequenceManagerNativeImpl).
>
> regards,
> Armin



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


Re: Problems using sequence-manger for MsSqlServer

Posted by Armin Waibel <ar...@code-au-lait.de>.
Hi,

Rogerio Tambellini wrote:
> It still not working... :-(
> Do I have to implement a store procedure and create OJB tables like 
> OJB_NEXTVAL_SEQ?
> 
SequenceManagerHighLowImpl use a DB table called OJB_HL_SEQ to manage 
the keys, but this table is part of the repository_internal.xml, thus 
you should generate it. More info about the OJB specific table can be 
found here http://db.apache.org/ojb/platforms.html

If you read the sequence manager doc
http://db.apache.org/ojb/sequencemanager.html
you can find other sequence manager implementations. One of this 
implementations use stored procedure to manage keys.

You can to to use *SequenceManagerInMemoryImpl* for your test. This 
implementation doesn't need any database tables.

Superfluous to say, do not define column "CdEmp" as Identity column (to 
use Identity columns you have to use SequenceManagerNativeImpl).

regards,
Armin

> My repository.xml:
> ....
> <sequence-manager
>      
> className="org.apache.ojb.broker.util.sequence.SequenceManagerHighLowImpl">
>      <attribute attribute-name="grabSize" attribute-value="20"/>
>      <attribute attribute-name="globalSequenceId" attribute-value="false"/>
>      <attribute attribute-name="globalSequenceStart" 
> attribute-value="10000"/>
>      <attribute attribute-name="autoNaming" attribute-value="true"/>
>  </sequence-manager>
> ....
>  <field-descriptor
>       id="1"
>       name="id"
>      column="CdEmp"
>      jdbc-type="INTEGER"
>      primarykey="true"
>      autoimcrement="true"
>      nullable="false"/>
> ....
> 
> and my table script on Ms Sql Server 2000:
> 
> CREATE TABLE [dbo].[Empresa] (
>    [CdEmp] [int] IDENTITY (1, 1) NOT NULL ,
>    [NmEmp] [varchar] (50) NOT NULL ) ON [PRIMARY]
> 
> where CdEmp is Identity and Primary key.
> 
> on the code I'm just doing...
> 
> Empresa empresa = new Empresa();
> empresa.setNome("Company name");
> broker.store(empresa);
> 
> It still continues to update the name of id equals to 0 in the table.
> 
> 
> Armin Waibel wrote:
> 
>> Hi,
>>
>> Rogerio Tambellini wrote:
>>
>>> I'm using OJB connecting to MsSqlServer, but I'm not able to 
>>> automatic increment a column into the column. I've added the 
>>> following line into the repository.xml:
>>>
>>> <sequence-manager
>>>     
>>> className="org.apache.ojb.broker.util.sequence.SequenceManagerHighLowImpl"> 
>>>
>>>    <attribute attribute-name="grabSize" attribute-value="1"/>
>>> </sequence-manager>
>>>
>> please set grabSize > 1, because 1 will eliminate the advantage of 
>> this implementation (default was 20).
>> see http://db.apache.org/ojb/sequencemanager.html
>>
>>> Primary key column in the table is set to Auto-Increment, but it's 
>>> still not working. When I store into the database, "store" operation 
>>> always updates the 0 id line.
>>>
>> hmm, if your field-descriptor looks like
>>
>> <field-descriptor
>>      name="articleId"
>>      column="ARTICLE_ID"
>>      jdbc-type="INTEGER"
>>      primarykey="true"
>>      autoincrement="true"
>>     />
>>
>> all should work well.
>>
>> regards,
>> Armin
>>
>>> Please, anyone has a implentation sample or a tutorial for 
>>> OJB+MsSqlServer? Or just a hint?
>>>
>>> Regards,
>>> Rogério
>>>
>>>
>>> ---------------------------------------------------------------------
>>> 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
>>
> 
> 
> ---------------------------------------------------------------------
> 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


Re: Problems using sequence-manger for MsSqlServer

Posted by Rogerio Tambellini <ro...@softtek.com>.
It still not working... :-(
Do I have to implement a store procedure and create OJB tables like 
OJB_NEXTVAL_SEQ?

My repository.xml:
....
 <sequence-manager
      
className="org.apache.ojb.broker.util.sequence.SequenceManagerHighLowImpl">
      <attribute attribute-name="grabSize" attribute-value="20"/>
      <attribute attribute-name="globalSequenceId" attribute-value="false"/>
      <attribute attribute-name="globalSequenceStart" 
attribute-value="10000"/>
      <attribute attribute-name="autoNaming" attribute-value="true"/>
  </sequence-manager>
....
  <field-descriptor
       id="1"
       name="id"
      column="CdEmp"
      jdbc-type="INTEGER"
      primarykey="true"
      autoimcrement="true"
      nullable="false"/>
....

and my table script on Ms Sql Server 2000:

CREATE TABLE [dbo].[Empresa] (
    [CdEmp] [int] IDENTITY (1, 1) NOT NULL ,
    [NmEmp] [varchar] (50) NOT NULL ) ON [PRIMARY]

where CdEmp is Identity and Primary key.

on the code I'm just doing...

Empresa empresa = new Empresa();
empresa.setNome("Company name");
broker.store(empresa);

It still continues to update the name of id equals to 0 in the table.


Armin Waibel wrote:

> Hi,
>
> Rogerio Tambellini wrote:
>
>> I'm using OJB connecting to MsSqlServer, but I'm not able to 
>> automatic increment a column into the column. I've added the 
>> following line into the repository.xml:
>>
>> <sequence-manager
>>     
>> className="org.apache.ojb.broker.util.sequence.SequenceManagerHighLowImpl"> 
>>
>>    <attribute attribute-name="grabSize" attribute-value="1"/>
>> </sequence-manager>
>>
> please set grabSize > 1, because 1 will eliminate the advantage of 
> this implementation (default was 20).
> see http://db.apache.org/ojb/sequencemanager.html
>
>> Primary key column in the table is set to Auto-Increment, but it's 
>> still not working. When I store into the database, "store" operation 
>> always updates the 0 id line.
>>
> hmm, if your field-descriptor looks like
>
> <field-descriptor
>      name="articleId"
>      column="ARTICLE_ID"
>      jdbc-type="INTEGER"
>      primarykey="true"
>      autoincrement="true"
>     />
>
> all should work well.
>
> regards,
> Armin
>
>> Please, anyone has a implentation sample or a tutorial for 
>> OJB+MsSqlServer? Or just a hint?
>>
>> Regards,
>> Rogério
>>
>>
>> ---------------------------------------------------------------------
>> 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
>


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