Recently, I've been using CMP 2.0 in JBoss 3.0.
In updating the CMP EJBs, I've received an error about a null primary key. (I also noticed, in the server log, that the other EJB values were null.) I've read a number of posts that have had similar problems, while other have said CMP 2.0 works great.
I found that CMP 2.0 in JBoss requires that one use the (abstract) "set" methods in ejbCreate. If not, then the values will not be set. Thus, there are null keys, etc.
Here's a bit from my (updated) JBoss CD tutorial.
public Integer ejbCreate (Integer id) throws CreateException
{
// CANNOT SET VARS USING SIMPLE VARIABLE REFERENCE
// this.id = id;
// IN JBOSS, MUST USE THE GET/SET METHODS....
setId(id);
return null;
}
In any case, the above worked for me, whereas the more common "this.id = id;" did not.
Bug or feature? You be the judge! :-)
Hope that helps someone.
The requirement that CMP2.0 fields be declared by using abstract getters and setters is not specific to JBoss, but is required by all CMP2.0 implementations. Do not declare your persistent fields as instance variables.