Hi,
it seems to be commonly agreed that clients should not directly access entity beans, but use session beans as Facade (=design pattern). This works fine as long as the entity beans are accessed via "bulk accessors" (aka value
objects). However, if the client needs to access the entities at a more fine-grained level, this approach gets soon unhandy, since all accessor methods of the entity bean have to be duplicated in the session bean.
Let's say, the entity bean has some methods:
public class MyEntity {
public Vector getA();
public Vector getB();
}
then, the session bean would have to look like this:
public class MySession {
public Vector getA(Object myEntityPrimaryKey) { ... }
public Vector getB(Object myEntityPrimaryKey) { ... }
}
This means, all accessor methods of the entity bean have to be duplicated in the session bean, which I don't see much sense in (?).
My questions:
1) What's so bad about letting the clients access the entities directly?
2) Using the Facade pattern, is there any better way of providing fine-grained access for the client?
thx
Heiko
P.S. In my case I can't use bulk accessors effectively, since the entities contain some complex attributes like Vectors and tree-like structures, and I would end up sucking the entire database into my bulk accessor object if I tried to resolve all these attributes
-
Session beans as Facade to entity beans (1 messages)
- Posted by: Heiko Gottschling
- Posted on: February 02 2001 11:57 EST
Threaded Messages (1)
- Session beans as Facade to entity beans by raghu tss rao on February 02 2001 13:25 EST
-
Session beans as Facade to entity beans[ Go to top ]
- Posted by: raghu tss rao
- Posted on: February 02 2001 13:25 EST
- in response to Heiko Gottschling
Each method call on a entity bean will be a remote call this can slow you down. If your getVecA() returned a collection it has to be another entity bean for it to give remotely available.