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 Mykola Ostapchuk <my...@sympatico.ca> on 2003/06/29 02:05:07 UTC
Update only some fields in DB
Hello,
This question already was in this maillist, but nobody answered.
It's actually so fundamental in use, that it must be somewhere in FAQ.
So, here it is: How can I update not all, but only some fields in some
table? I'm using PersistenceBroker.store method to persist an object - and
if I don't populate all the object properties with values, I get null rows
in DB in place of unspecified object properties...
At least, please, answer if it's possible with OJB.
Best regards,
Mykola Ostapchuk
Re: Update only some fields in DB
Posted by Christophe Marcourt <cm...@wanadoo.fr>.
I think it's possible.
Before update your object you need to get it from DB with a
getObjectByQuery() method call, than you can only update the fileds you
need.
See tutorial 1 : Updating Objects.
Christophe
----- Original Message -----
From: "Mykola Ostapchuk" <my...@sympatico.ca>
To: <oj...@db.apache.org>
Sent: Sunday, June 29, 2003 2:05 AM
Subject: Update only some fields in DB
> Hello,
>
> This question already was in this maillist, but nobody answered.
> It's actually so fundamental in use, that it must be somewhere in FAQ.
>
> So, here it is: How can I update not all, but only some fields in some
> table? I'm using PersistenceBroker.store method to persist an object - and
> if I don't populate all the object properties with values, I get null rows
> in DB in place of unspecified object properties...
> At least, please, answer if it's possible with OJB.
>
>
> Best regards,
> Mykola Ostapchuk
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
---
Ce message Envoi est certifié sans virus connu.
Protégé par l'antivirus AVG Deluxe.
Version: 6.0.492 / Base de données virus: 291 - Date: 24/06/2003
Re: Update only some fields in DB
Posted by Mykola Ostapchuk <my...@sympatico.ca>.
Sorry, Thomas, maybe I wasn't clear enough in my question. I need to update
both - in one case - all fields, in another - just some fields.
So, modifying ClassDescriptor to accept only particular fields will help
only with one case...
For now, according to Christophe Marcout, the only way to accomplish my task
is to get an Object from DB with a
getObjectByQuery() method call first, then set any of updates I want.
So, to make this "universal" update - I need 2 steps - 2 database calls -
Select Object - Store Object.
With SQL language, as we know, there's just one DB call for Update.
Is this way really the only way to make update with OJB?
Best regards,
Mykola
----- Original Message -----
From: "Thomas Mahler" <th...@web.de>
To: "OJB Users List" <oj...@db.apache.org>
Sent: Sunday, June 29, 2003 5:13 AM
Subject: Re: Update only some fields in DB
> Hi
>
> Mykola Ostapchuk wrote:
> > Hello,
> >
> > This question already was in this maillist, but nobody answered.
>
> I answered it on 19.6.:
>
> You can modify the ClassDescriptor of your peristent class to only
> contain FieldDescriptors of the the PK and modified field.
>
> OJB will then only work with those two columns!
>
> cheers,
> Thomas
>
> > It's actually so fundamental in use, that it must be somewhere in FAQ.
> >
> > So, here it is: How can I update not all, but only some fields in some
> > table? I'm using PersistenceBroker.store method to persist an object -
and
> > if I don't populate all the object properties with values, I get null
rows
> > in DB in place of unspecified object properties...
> > At least, please, answer if it's possible with OJB.
> >
> >
> > Best regards,
> > Mykola Ostapchuk
> >
> >
> > ---------------------------------------------------------------------
> > 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: Update only some fields in DB
Posted by Thomas Mahler <th...@web.de>.
Hi
Mykola Ostapchuk wrote:
> Hello,
>
> This question already was in this maillist, but nobody answered.
I answered it on 19.6.:
You can modify the ClassDescriptor of your peristent class to only
contain FieldDescriptors of the the PK and modified field.
OJB will then only work with those two columns!
cheers,
Thomas
> It's actually so fundamental in use, that it must be somewhere in FAQ.
>
> So, here it is: How can I update not all, but only some fields in some
> table? I'm using PersistenceBroker.store method to persist an object - and
> if I don't populate all the object properties with values, I get null rows
> in DB in place of unspecified object properties...
> At least, please, answer if it's possible with OJB.
>
>
> Best regards,
> Mykola Ostapchuk
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>