If a entity bean was deisgned for the container managed persistence, it must be coded as a local acess one, is it righ? And why?
No, it does not *HAVE* to use only local interfaces. CMP beans have always had remote interfaces. The locals are new as of the EJB 2.0 spec.
However, they typically have been "hidden" behind session beans, where the actual logic utilizing the data from the entity beans is manipulated and used. Using a stateless session bean to entity bean via a local interface is faster than a remote call (even though many app server vendors optimized this when both beans are in the same classloader).
I want to know if there are some container managed relationships(CMR), does the bean which was the target of the CMR have to be coded as local acess, thanks
because it was said that "Container-managed relationships: If an entity bean is the target of a container-managed relationship, it must use local access", cited from the j2ee tutorial
You didn't specify CMR in your original question, but, yes, if an EntityBean is involved in a CMR, it must provide a local interface to implement the relationship.
You can still have remote interfaces on it -- although that would probably lead to data synchronization issues.