Hi Guys, I havn't done all that much of EJB. I had a basic question. If I am
referencing one Entity bean from another, how does this get handled. Is the
container smart enough to know that it doesn't need to passivate the entire
referenced bean and only stores some kind of a reference from one bean to
another.
Lets say I have a entity bean called "Fruit"
From another entity bean, say "Farm" I set this via a method
Farm.setFruit(Fruit apple);
within Farm I have Fruit as a instance variable, something like
public Fruint fruit=null;
public void setFruit(Fruit f) {
this.fruit = f;
}
How will this apple be handled when I set it to this beans Fruit ??
Is this dependent on the container, How will say Weblogic handle as compared
to JBoss ???
Heeeeeeeelp
Thanks
cheers
Haider
Johann Burkard - 29 Oct 2003 19:26 GMT
> Hi Guys, I havn't done all that much of EJB. I had a basic question. If I am
> referencing one Entity bean from another, how does this get handled. Is the
[quoted text clipped - 14 lines]
> this.fruit = f;
> }
I assume you are using CMP (Container Managed Persistence), right? With
CMP, there's no need to have instance variables for CMR (Container
Managed Relationships) fields. Instead, you'd use abstract getters and
setters and the local interface.
public interface FarmLocal extends EJBLocalObject {
public void setFruit(FruitLocal f);
public FruitLocal getFruit();
}
public class FarmEJB implements EntityBean {
public abstract void setFruit(FruitLocal f);
public abstract FruitLocal getFruit();
}
Johann

Signature
`/()|_| (/-\|\| |-|/-\\/3 |\/|`/ |3/-\|\||)\/\/||)7|-| ||°|-| `/()|_|
/-\5|< |\||(3|_`/
Marcus Beyer - 05 Nov 2003 13:23 GMT
> Hi Guys, I havn't done all that much of EJB. I had a basic question. If I am
> referencing one Entity bean from another, how does this get handled. Is the
> container smart enough to know that it doesn't need to passivate the entire
> referenced bean and only stores some kind of a reference from one bean to
> another.
"In JBoss, EJBs thus are a robust data cache for the web layers. A
typical web application will use servlet/JSP and your favorite portal
application to access the EJBs. Since EJBs carry their own optimized
caches, we would think that we can work at in-memory speed throughout
our stack. Unfortunately, by specification, the EJBs are remote and
require the usage of the pass by copy semantic. Serialization is back in
full force even as the web layer communicates directly with the EJB
container (Tomcat in JBoss is optimized in that way). The specification
deals with this in a very “spec heavy” way that requires you to use
local interfaces to achieve a very simple result. This is a clear case
of the spec gone wild, looping onto its own logic and patching
spec-created problems by adding yet another intrusive layer of
complexity in the application design. Local interfaces are a
“spec patch” not a first class citizen. In JBoss, we optimize away this
RPC layer, transparently and automatically to the EJB programmer."
from: http://www.jboss.org/modules/html/blue.pdf
Don't know how this is handled by other products ...
Marcus
Marcus Beyer - 05 Nov 2003 16:24 GMT
[2nd try]
> Hi Guys, I havn't done all that much of EJB. I had a basic question. If I am
> referencing one Entity bean from another, how does this get handled. Is the
> container smart enough to know that it doesn't need to passivate the entire
> referenced bean and only stores some kind of a reference from one bean to
> another.
"In JBoss, EJBs thus are a robust data cache for the web layers. A
typical web application will use servlet/JSP and your favorite portal
application to access the EJBs. Since EJBs carry their own optimized
caches, we would think that we can work at in-memory speed throughout
our stack. Unfortunately, by specification, the EJBs are remote and
require the usage of the pass by copy semantic. Serialization is back in
full force even as the web layer communicates directly with the EJB
container (Tomcat in JBoss is optimized in that way). The specification
deals with this in a very “spec heavy” way that requires you to use
local interfaces to achieve a very simple result. This is a clear case
of the spec gone wild, looping onto its own logic and patching
spec-created problems by adding yet another intrusive layer of
complexity in the application design. Local interfaces are a
“spec patch” not a first class citizen. In JBoss, we optimize away this
RPC layer, transparently and automatically to the EJB programmer."
from: http://www.jboss.org/modules/html/blue.pdf
Don't know how this is handled by other products ...
Marcus