thanks a lot!!!! i do not load the data from DB first, so this morning i could not get my anticipated result.
then i read through ojb-user mail List, and find some information indicate that i should initialize myList = new new RemovalAwareCollection(); so i change myList = new ArrayList(); to myList = new new RemovalAwareCollection(); it works! that's great!!!! Thanks for your help! ----- Original Message ----- From: "Thomas Mahler" <[EMAIL PROTECTED]> To: "OJB Users List" <[EMAIL PROTECTED]> Sent: Tuesday, December 02, 2003 3:51 PM Subject: Re: ask RemovalAwareCollection again > Hi Gong, > > You declare your collection attribute as java.util.List. That's fine! > > But then you have to be careful: > > If you *load* you collection from the db first, then OJB will > automagically use a RemovalAwareCollection to fill your collection > attribute. > > But if you do not load the collectio from the DB you have to make sure > that you initialize the collection attribute with a > RemovalAwareCollection instance. > > List mylist; > myList = new RemovalAwareCollection(); > > cheers, > Thomas > > > > gong wrote: > > I tried it, but it did not work. > > the entry still remain in the database and can be retrieved. > > > > I used java.util.List for collection, but it fails. > > Is that mean i should use > > org.apache.ojb.broker.util.collections.RemovalAwareCollection in my java > > code? > > > > > > > > > > ----- Original Message ----- > > From: <[EMAIL PROTECTED]> > > To: <[EMAIL PROTECTED]> > > Sent: Monday, December 01, 2003 10:08 PM > > Subject: RemovalAwareCollection, was: RE: does > > PersistenceBroker.getCollectionByQuery use the cache? > > > > > > > >>Hello Gong, > >> > >>please start a new thread when you ask a new question. > >> > >> > >>>-----Original Message----- > >> > >>>class myList and myEntry has a 1:n relationship > >>>each myList has a collection of myEntry(s) > >> > >>[..] > >> > >> > >>> <collection-descriptor > >>> name="entries" > >>> > >>>collection-class= > >>>"org.apache.ojb.broker.util.collections.ManageableArrayList" > >>> element-class-ref="myEntry" > >>> auto-retrieve="true" > >>> auto-update="true" > >>> auto-delete="true" > >>> > > >>> <inverse-foreignkey field-ref="listId"/> > >>> </collection-descriptor> > >>> > >>></class-descriptor> > >> > >>[..] > >> > >> > >>>in this way, listPersisiter.store() and get() can automatically > >>>store and retrieve entry. > >>> > >>>but when i retrieve myList, and remove an entry from > >>>myList.entries, and store back, it can not automatically > >>>delete the entry in DB which have been removed from > >>>myList.entries. > >> > >>If you want this behaviour, you must not use > >>the ManageableArrayList (as you explicitly do, see above) > >>but have to use the RemovalAwareCollection (which is > >>actually the default.) > >> > >>Just remove the attribute collection-class from the > >>class-descriptor and try again. > >> > >>BTW: this is a FAQ. > >> > >>Olli > >> > >>--------------------------------------------------------------------- > >>To unsubscribe, e-mail: [EMAIL PROTECTED] > >>For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED]
