[jboss-user] [EJB/JBoss] - Jboss Mysql unknown primary key

teodoro21 do-not-reply at jboss.com
Wed Feb 14 02:57:10 EST 2007

I'm trying to develope a CMP entity bean under jboss with mysql db.
I'd want that my CMP entity bean has an autoincrement primary key.

The following is part of my: standardjbosscmp-jdbc.xml

 <entity-command name="default"/>

  I have deployed my entity bean without problems and the following
 is my deployment descriptor:




NB: I don't specify cmp id field! It is correct?

When I have deployed entity bean the created table have
id,name,surname and mobile fields


public interface FirstHomeRemote extends javax.ejb.EJBHome{
 public FirstRemote create() throws CreateException, RemoteException;
 public FirstRemote findByPrimaryKey(Object pk) throws
FinderException, RemoteException;



 public Object ejbCreate()throws CreateException{
   return null;

 public void ejbPostCreate(){

In this class I don't have implemented cmp field id.

The FirstRemote class contains abstract methods: setName(),getName()

Now let's see the client:

   Context jndiContext = getInitialContext(); // get jnp://localhost: 1099 etc..
   Object ref = jndiContext.lookup("FirstEJB");
   FirstHomeRemote home = (FirstHomeRemote)

    FirstRemote myfirst = (FirstRemote)home.create();

   the statement:  FirstRemote myfirst = (FirstRemote)home.create();

    return exception: javax.ejb.CreateException: Primary key for created instance is null.

    Within table 'MySchema' I see that id (autoincrement primary key)
    is added  and Jboss server.log don't return errors but all others fields are empty, so I don't be 
    able to figure It out this problem.

thanks Teo 

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4016230#4016230

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4016230

More information about the jboss-user mailing list