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 Björn Agel <b....@t-online.de> on 2007/04/16 16:15:57 UTC
best solution for updating many objects ?
hi,
say we have a table, where many thousands objects with about 30 fields
are stored.
Now I want to update only 1 of these 30 colums for a few hundred objects.
Atm I retrieve every single object, change 1 value and store it ...
What is the best solution for this task ?
Is there anything similar to the "ALTER TABLE" statement ?
with best regards,
Björn Agel
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: best solution for updating many objects ?
Posted by Vasily Ivanov <ba...@gmail.com>.
Sorry, can't help. I'm using Spring Jdbc abstraction to do plain sql calls.
Cheers,
Vasily
On 4/19/07, Björn Agel <b....@t-online.de> wrote:
> can you give a code example pls ?
>
> im sticking in how to execute plain sql with ojb ...
>
> thank,
> Björn
>
> Vasily Ivanov wrote:
> > Hi Björn,
> >
> > I usually do retrieve list of IDs via OJB's
> > getReportQueryIteratorByQuery and then run simple plain SQL to bulk
> > update one field in each record by id.
> >
> > Cheers,
> > Vasily
> >
> > On 4/17/07, Björn Agel <b....@t-online.de> wrote:
> >> hi,
> >>
> >> say we have a table, where many thousands objects with about 30 fields
> >> are stored.
> >> Now I want to update only 1 of these 30 colums for a few hundred
> >> objects.
> >>
> >> Atm I retrieve every single object, change 1 value and store it ...
> >>
> >> What is the best solution for this task ?
> >> Is there anything similar to the "ALTER TABLE" statement ?
> >>
> >> with best regards,
> >> Björn Agel
> >
> > ---------------------------------------------------------------------
> > 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: best solution for updating many objects ?
Posted by Björn Agel <b....@t-online.de>.
thanks,
thats what i am searching for ;)
regards,
Björn
Armin Waibel wrote:
> Hi Björn,
>
> Björn Agel wrote:
>> can you give a code example pls ?
>>
>> im sticking in how to execute plain sql with ojb ...
>>
>
> you can lookup Statements from the connection and perform the update
> by your own
> http://db.apache.org/ojb/docu/guides/connection.html#Can+I+directly+obtain+a
>
>
>
> or you can use OJB service classes:
>
> broker.beginTransaction();
> ClassDescriptor cld = broker.getClassDescriptor(Article.class);***
> int result = broker.serviceJdbcAccess().executeUpdateSQL("UPDATE
> ARTICLE A0 SET A0.TAX='23' WHERE A0.ID IN ('7','23', '34')", cld);
> broker.commitTransaction();
>
> *** If you execute plain SQL it should work with every
> class-descriptor, no need to specify the correct one (but I never
> tried this).
>
> regards,
> Armin
>
>
>> thank,
>> Björn
>>
>> Vasily Ivanov wrote:
>>> Hi Björn,
>>>
>>> I usually do retrieve list of IDs via OJB's
>>> getReportQueryIteratorByQuery and then run simple plain SQL to bulk
>>> update one field in each record by id.
>>>
>>> Cheers,
>>> Vasily
>>>
>>> On 4/17/07, Björn Agel <b....@t-online.de> wrote:
>>>> hi,
>>>>
>>>> say we have a table, where many thousands objects with about 30 fields
>>>> are stored.
>>>> Now I want to update only 1 of these 30 colums for a few hundred
>>>> objects.
>>>>
>>>> Atm I retrieve every single object, change 1 value and store it ...
>>>>
>>>> What is the best solution for this task ?
>>>> Is there anything similar to the "ALTER TABLE" statement ?
>>>>
>>>> with best regards,
>>>> Björn Agel
>>>
>>> ---------------------------------------------------------------------
>>> 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: best solution for updating many objects ?
Posted by Armin Waibel <ar...@apache.org>.
Hi Björn,
Björn Agel wrote:
> can you give a code example pls ?
>
> im sticking in how to execute plain sql with ojb ...
>
you can lookup Statements from the connection and perform the update by
your own
http://db.apache.org/ojb/docu/guides/connection.html#Can+I+directly+obtain+a
or you can use OJB service classes:
broker.beginTransaction();
ClassDescriptor cld = broker.getClassDescriptor(Article.class);***
int result = broker.serviceJdbcAccess().executeUpdateSQL("UPDATE ARTICLE
A0 SET A0.TAX='23' WHERE A0.ID IN ('7','23', '34')", cld);
broker.commitTransaction();
*** If you execute plain SQL it should work with every class-descriptor,
no need to specify the correct one (but I never tried this).
regards,
Armin
> thank,
> Björn
>
> Vasily Ivanov wrote:
>> Hi Björn,
>>
>> I usually do retrieve list of IDs via OJB's
>> getReportQueryIteratorByQuery and then run simple plain SQL to bulk
>> update one field in each record by id.
>>
>> Cheers,
>> Vasily
>>
>> On 4/17/07, Björn Agel <b....@t-online.de> wrote:
>>> hi,
>>>
>>> say we have a table, where many thousands objects with about 30 fields
>>> are stored.
>>> Now I want to update only 1 of these 30 colums for a few hundred
>>> objects.
>>>
>>> Atm I retrieve every single object, change 1 value and store it ...
>>>
>>> What is the best solution for this task ?
>>> Is there anything similar to the "ALTER TABLE" statement ?
>>>
>>> with best regards,
>>> Björn Agel
>>
>> ---------------------------------------------------------------------
>> 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: best solution for updating many objects ?
Posted by Björn Agel <b....@t-online.de>.
can you give a code example pls ?
im sticking in how to execute plain sql with ojb ...
thank,
Björn
Vasily Ivanov wrote:
> Hi Björn,
>
> I usually do retrieve list of IDs via OJB's
> getReportQueryIteratorByQuery and then run simple plain SQL to bulk
> update one field in each record by id.
>
> Cheers,
> Vasily
>
> On 4/17/07, Björn Agel <b....@t-online.de> wrote:
>> hi,
>>
>> say we have a table, where many thousands objects with about 30 fields
>> are stored.
>> Now I want to update only 1 of these 30 colums for a few hundred
>> objects.
>>
>> Atm I retrieve every single object, change 1 value and store it ...
>>
>> What is the best solution for this task ?
>> Is there anything similar to the "ALTER TABLE" statement ?
>>
>> with best regards,
>> Björn Agel
>
> ---------------------------------------------------------------------
> 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: best solution for updating many objects ?
Posted by Vasily Ivanov <ba...@gmail.com>.
Hi Björn,
I usually do retrieve list of IDs via OJB's
getReportQueryIteratorByQuery and then run simple plain SQL to bulk
update one field in each record by id.
Cheers,
Vasily
On 4/17/07, Björn Agel <b....@t-online.de> wrote:
> hi,
>
> say we have a table, where many thousands objects with about 30 fields
> are stored.
> Now I want to update only 1 of these 30 colums for a few hundred objects.
>
> Atm I retrieve every single object, change 1 value and store it ...
>
> What is the best solution for this task ?
> Is there anything similar to the "ALTER TABLE" statement ?
>
> with best regards,
> Björn Agel
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org