| Which fields are eligible for CMP? |
|
The only restrictions the EJB specification gives regarding CMP fields is that they must be public and not transient. In practice they should also be non-static and non-final. If we allow static finals then serialVersionUID is a candidate for CMP. Also, in general, static fields are NOT allowed in ANY EJB implemenations. The reason is that the semantics of static cannot be enforced in a distributed environment. For example, if I have instances of the same EJB implementation class in two different VMs (a very useful thing, for performance reasons) then the static field is not shared among the instances.
|