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 Joose Vettenranta <jo...@iki.fi> on 2004/07/26 11:08:10 UTC

Re: removing a child from 1:n [SOLVED] [WORKING]

I just wanted to say, that I got it to work.. I did it so, that in the  
Child i made delete -variable which is checked on update-action (not  
very good if there is million child).

So my DAO.update() is like this now:

         public void update(Parent bean, JdoPMF pmf) {
                 PersistenceManager persistenceManager =  
pmf.getPersistenceManager();
                 PersistenceBroker broker =  
PersistenceBrokerFactory.defaultPersistenceBroker();
                 Iterator it = bean.getChilds().iterator();

                 broker.beginTransaction();
                 while (it.hasNext()) {
                         Child child = it.next();
                         if (child.getDelete()) {
                                 broker.delete(child);
                                 it.remove();
                         }
                 }
                 broker.store(bean,  
ObjectModificationDefaultImpl.UPDATE);
                 broker.commitTransaction();
                 broker.close();
         }

and it works.

Thanks,

Joose

26.7.2004 kello 11:36, Joose Vettenranta kirjoitti:


> 24.7.2004 kello 21:09, Jakob Braeuchi kirjoitti:
>
>  hi joose,
>>
>> i assume you're using pb-api now. please check the following doku:
>>
>> http://db.apache.org/ojb/docu/guides/basic-technique.html#1%3An+auto- 
>> xxx+setting
>
> Seems like auto-update does only INSERT or UPDATE. and auto-delete  
> removes everything.
>
> So seems like I just have to do PersistenceBroker.delete(...) to every  
> deleted child to get them deleted.
>
> Thanks,
>
> Joose
>
> --
> "Always remember that you are unique, just like everyone else!"
> * http://iki.fi/joose/ * joose@iki.fi * +358 44 561 0270 *
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>
--
"Always remember that you are unique, just like everyone else!"
* http://iki.fi/joose/ * joose@iki.fi * +358 44 561 0270 *


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