You are absolutely right!  I am seeing the same behavior.  You should file
a bug with BEA.

I tried a few ways of getting around the problem.  The following code -
which is very clumsy - works!

You may already know this, or you may have your own variation :)

But here it is...


            Collection beanB = beanA.getBeanBs();
            Iterator itr = beanB.iterator();

            while (itr.hasNext()) {
                BeanBLocalEntity beanBLocal
                    = (BeanBLocalEntity) itr.next();
                beanBLocal.remove();

                //Since 'remove' changes the underlying collection,
                //I had to update it....  otherwise I got 
'ConcurrentModificationException'!
                //(This is for testing only..I am sure this code can be
improved..a lot!)

                beanB = beanA.getBeanBs();
                itr = beanB.iterator();
            }

Thanks.

>-- Original Message --
>Date: Mon, 20 Jan 2003 12:53:48 -0800
>From: "Ajay Chitre" <[EMAIL PROTECTED]>
>Subject: Re: Relationship deletion question
>Reply-To: [EMAIL PROTECTED]
>To: "Justin Wesbrooks" <[EMAIL PROTECTED]>,
> [EMAIL PROTECTED]
>
>
>Oh, I see what you are trying to do!  Let me try that and see what happens.
>
>Got to go to a meeting though.  Will get back to you later!
>
>Thanks.
>
>>-- Original Message --
>>Date:         Mon, 20 Jan 2003 12:43:02 -0800
>>Reply-To: Justin Wesbrooks <[EMAIL PROTECTED]>
>>From: Justin Wesbrooks <[EMAIL PROTECTED]>
>>Subject:      Re: Relationship deletion question
>>To: [EMAIL PROTECTED]
>>
>>
>>Sorry, I missed what you were saying.  I'm not actually trying to delete
>>Bean A though.
>>It's remaining, just the associated Bean B objects need to be removed.
>>
>>
>>
>>
>>|---------+------------------------------>
>>|         |           "Ajay Chitre"      |
>>|         |           <ajay.chitre@dilige|
>>|         |           ntteam.com>        |
>>|         |                              |
>>|         |           01/20/2003 12:39 PM|
>>|         |           Please respond to  |
>>|         |           Ajay.Chitre        |
>>|         |                              |
>>|---------+------------------------------>
>>  
>>---------------------------------------------------------------------------------------------------------------|
>>  |
>
>>                                         |
>>  |        To:      "Justin Wesbrooks" <[EMAIL PROTECTED]>, 
>[EMAIL PROTECTED]
>>                        |
>>  |        cc:
>
>>                                         |
>>  |        Subject: Re: Relationship deletion question
>
>>                                         |
>>  
>>---------------------------------------------------------------------------------------------------------------|
>>
>>
>>
>>
>>Actually I am calling 'remove' only once for BeanA.  The "cascade delete"
>>takes care of iteration.  I had to set 'cascade delete' only on BeanB.
>>
>>
>>
>>>-- Original Message --
>>>Date:         Mon, 20 Jan 2003 12:33:54 -0800
>>>Reply-To: Justin Wesbrooks <[EMAIL PROTECTED]>
>>>From: Justin Wesbrooks <[EMAIL PROTECTED]>
>>>Subject:      Re: Relationship deletion question
>>>To: [EMAIL PROTECTED]
>>>
>>>
>>>I have tried the <cascade-delete/> setting with no difference in results.
>>>
>>>I don't call remove on each individual bean because I don't want to have
>>>to
>>>iterate through
>>>the collection when one call should do what I need it to (and does in
>the
>>>other instance).
>>>
>>>Thanks
>>>
>>>
>>>
>>>|---------+------------------------------>
>>>|         |           "Ajay Chitre"      |
>>>|         |           <ajay.chitre@dilige|
>>>|         |           ntteam.com>        |
>>>|         |                              |
>>>|         |           01/20/2003 12:29 PM|
>>>|         |           Please respond to  |
>>>|         |           Ajay.Chitre        |
>>>|         |                              |
>>>|---------+------------------------------>
>>>  >
>>---------------------------------------------------------------------------------------------------------------|
>>
>>>  |
>>
>>>                                         |
>>>  |        To:      "Justin Wesbrooks" <[EMAIL PROTECTED]>,
>>[EMAIL PROTECTED]
>>>                        |
>>>  |        cc:
>>
>>>                                         |
>>>  |        Subject: RE: Relationship deletion question
>>
>>>                                         |
>>>  >
>>---------------------------------------------------------------------------------------------------------------|
>>
>>>
>>>
>>>
>>>
>>>Justin,
>>>
>>>Have you tried setting <cascade-delete/> on BeanB?  If you haven't, can
>>>you please try and tell us what happens.
>>>
>>>Also, try 'beanA.remove()' as opposed to 'beanA.getBeanBs().clear()'.
>>>
>>>This works for me for '1:N relationships'.
>>>
>>>Thanks.
>>>
>>>>-- Original Message --
>>>>Date:         Mon, 20 Jan 2003 11:20:18 -0800
>>>>Reply-To: Justin Wesbrooks <[EMAIL PROTECTED]>
>>>>From: Justin Wesbrooks <[EMAIL PROTECTED]>
>>>>Subject:      Relationship deletion question
>>>>To: [EMAIL PROTECTED]
>>>>
>>>>
>>>>AppServer: WLS 7.0
>>>>
>>>>I have 2 beans with a 1:N relationship.  BeanA has a Collection
>>>>of BeanB.  I try to call BeanA.getBeanBs().clear().   All items
>>>>are removed from the Collection, however, nothing is removed
>>>>from the underlying database.   I have another situation similar to
>>>>this one and the exact same call works.  I'll highlight the differences
>>>>in the 2 below.
>>>>
>>>>Working situation
>>>>=====================
>>>>True M:N relationship with CMP (as outlined in Ed Roman book).
>>>>String as primary key (no primary key class)
>>>>clear() removes all records from the association table.
>>>>
>>>>Non-working situation
>>>>=====================
>>>>1:N relationship
>>>>The collection class has compound PK class.
>>>>The collection class also has a M:1 relationship with another CMP bean.
>>>>(This is kind of like the "Fake M:N relationship described in the Ed
>>Roman
>>>>book)
>>>>
>>>>Both of these calls are made in a Stateless Session bean.  Can
>>>>someone point me to some literature on this or provide any insight??
>>>>
>>>>
>>>
>>===========================================================================
>>>>To unsubscribe, send email to [EMAIL PROTECTED] and include in the
>>>body
>>>>of the message "signoff EJB-INTEREST".  For general help, send email
>to
>>>>[EMAIL PROTECTED] and include in the body of the message "help".
>>>>
>>>
>>>
>>===========================================================================
>>>To unsubscribe, send email to [EMAIL PROTECTED] and include in the
>>body
>>>of the message "signoff EJB-INTEREST".  For general help, send email
to
>>>[EMAIL PROTECTED] and include in the body of the message "help".
>>>
>>
>>Ajay Chitre
>>
>>Diligent Team, Inc.
>>(Where Diligent People Work as a Team)
>>
>>http://www.DiligentTeam.com
>>
>>===========================================================================
>>To unsubscribe, send email to [EMAIL PROTECTED] and include in the
>body
>>of the message "signoff EJB-INTEREST".  For general help, send email to
>>[EMAIL PROTECTED] and include in the body of the message "help".
>>
>
>

==========================================================================To 
unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to