It has been a long time since I looked at this stuff, but I'm not sure an entity can remove itself. The one thing I know for certain, is that calling the ejbRemove remove method has not effect on the entity state. The ejbRemove method is a callback invoked by the entity container when the entity container has decided to remove the entity. If you call this method directly, the entity container does not see this.

After reviewing the 2.1 spec, I can't see any where that specifies that entity can remove itself. Every remove example, has another bean removing the target bean. At the very least, I'd start by marking the entity as reentrant since a remove is conceivably reentrancy. Then I'd try, entityContext.getEJB[Local]Object().remove()

-dain

On Jul 10, 2006, at 10:56 PM, D. Strauss wrote:

Hello, Markus

try this:

Way a (the Collection way):
java.util.Collection<EjbLocal> c=ejbHome.findAll();
EjbLocal delBean=null;
for(EjbLocal l : c){
        //find the bean you want to remove: for now, find the last one
        delBean=l;
}
c.remove(delBean);

Way b (the usual way):
EjbLocal delBean=ejbHome.findByPrimaryKey(12);
delBean.remove();

Best regards

Dirk

mahu2425 schrieb:
Hello Dirk,

I'm not sure what you mean by "collection version of ejbRemove()".

Could you please explain it a little bit more?


Thank in advance,

Markus




Hello, Markus

now I get it ^^ (at least I think so)

So, to summarize it: you work with a CMP bean that is used by various other beans (JMS in particular). After all things have been done I want
to remove the bean?

Using ejbRemove() is OK but you may want to use the Collection version of ejbRemove. I think (if I remember correctly) that ejbRemove() always
crashed the EJB container. So I used the collection method. It is a
little bit difficult but it worked.

Give it a try and tell us if it works.

Best regards

Dirk

Schnell und einfach ohne Anschlusswechsel zur Lycos DSL Flatrate wechseln und 3 Monate kostenlos ab effektiven 5,21 EUR pro Monat im ersten Jahr surfen. http://www.lycos.de/startseite/online/dsl/index.html? prod=DSL&trackingID=email_footertxt

Reply via email to