Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Use of CMR fields from Client

 
Balaji Akella
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My question is with reference to the following line from the spec.
"The accessor methods for the container-managed relationship fields must not be exposed in the remote interface of an entity bean." Section 10.3.1, page 129.
If the CMR fields are not exposed to the clients through the remote interface, how can the client program can manipulate or use the relationship data?
Swamy
SCJP1.2, SCWCD
[ October 31, 2003: Message edited by: Swaminath Akella ]
 
somkiat puisungnoen
Ranch Hand
Posts: 1312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
CMR-fields are maintained by container (Local Only),
Control/Manage CMR-fields are config in Deployment Descriptor(ejb-jar file)

Please see 10.3.6 (Semantics of assignment for relationships) EJB 2.0 Spec
 
Bob Walker Jr
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Swaminath Akella:
My question is with reference to the following line from the spec.
"The accessor methods for the container-managed relationship fields must not be exposed in the remote interface of an entity bean." Section 10.3.1, page 129.
If the CMR fields are not exposed to the clients through the remote interface, how can the client program can manipulate or use the relationship data?
Swamy
SCJP1.2, SCWCD

I'm not an expert but here is my guess:
By using the local interfaces. It is possible for a bean that does not have any remote interface to participate in a relationship. So exposing the cmr fields through the remote interface of the second bean does not make any sense.
 
Kathy Sierra
Cowgirl and Author
Rancher
Posts: 1589
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Howdy -- you can't expose the CMR fields through a Remote interface, because the CMR fields are always the local interface of an entity (or a Collection of them). In fact, you can't EVER expose a local interface reference through a Remote method, so really, the rules for CMR in this case aren't any different from any other type of local interface reference.
But... you *can* expose them through a local interface. You probably shouldn't, and won't, since it is nearly *always* better to offer your *own* methods -- exposing ANY of an CMP bean's 'virtual fields' is really an ecapsulation violation, when you think about it.
So, you'll normally have your *own* business methods that are written specifically for the client, and that may *use* your CMR fields, but not retun the value of the CMR field directly.
For example, you might have a Customer bean that has a CMR field for its Address. But the client doesn't/shouldn't know that the Customer's address is another BEAN -- the client just wants the darn *address* in some easy-to-use form -- maybe you'll expose multiple methods to change street, city, zip, whatever or you'll use some kind of value object that just encapsulates the data of the address.
Cheers,
Kathy
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic