> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]]On Behalf Of David
> Jencks
> Sent: Saturday, June 16, 2001 8:06 AM
> To: [EMAIL PROTECTED]
> Subject: Re: [JBoss-dev] ejbStore() delay seems to be a serious problem
>
>
> Hi,
> A couple of comments
>
> 1. I think the worst problems can be eliminated by simply extending Bill's
> "store before load" to include "store before remove" and possibly "store
> before create" although I don't have an example of why the last one would
> help.
>

BTW, its "store before find" not "store before load".  The finder solution I
put in CANNOT be extended to fix the problem David Esposito is having.
"store before find" only effect entities of the same type.  In David
Esposito's example:

---------------------------
A.setAddress(newAddress)
oldAddress.remove()

delete happens before update thus constraint on bean A is violated, or if ON
DELETE CASCADE, bean A gets deleted.
---------------------------

There are 2 types of beans here Bean A and Address.  My code does not keep
track of all Entities within the transaction.

Wouldn't a better solutions to have some kind of flush capability for each
Entity?  In this way, you can fine tune your app in anyway you want.
(Personally, in our app, we're more worried about too many DB updates rather
than this scenario.  We NEVER call bean.remove() but rather mark the row as
deleted.)

1. Change JBoss to expose a flush method.

A.setAddress(newAddress)
((ImaginaryJBossEntityProxy)A).flush(); // Causes an ejbStore()/Update.
oldAddress.remove();

2. Or, as I think somebody else suggested:

A.setAddress(newAddress)
AHome.findByPrimaryKey(new APK(A.getId())); // causes a ejbStore/Update.
oldAddress.remove();

3. Even better, have all your entity beans implement flush(), just in case
the ejb spec or jboss comes up with a better solution you can easily change
it.

// CMP
class YourBean implements EntityBean
public void flush() throws RemoteException
{
        home.findByPrimaryKey(new MyPK(this.getId());
}

// BMP: Is this a good solution?

class YourBean implements EntityBean
public void flush() throws RemoteException
{
        this.ejbStore();  // Will this work?
}

BTW, GOOD stuff Mr. Esposito!

Bill



_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to