Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Java Beans > CMP entity bean...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 1 Topic 1286 of 1363
Post > Topic >>

CMP entity bean - javax.ejb.CreateException: Primay key for created instance is null

by "rs232" <rs232@[EMAIL PROTECTED] > Feb 8, 2007 at 01:01 PM

Hi,
I'm trying to develope a CMP entity bean under jboss with mysql db.
My entity bean must have an autoincrement primary key.

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

 <unknown-pk>
  <key-generator-factory>UUIDKeyGeneratorFactory</key-generator-
factory>
  <unknown-pk-class>java.lang.Object</unknown-pk-class>
  <field-name>id</field-name>
  <column-name>id</column-name>
  <jdbc-type>INTEGER</jdbc-type>
  <sql-type>INT(11)</sql-type>
  <auto-increment/>
 </unknown-pk>
 <entity-command name="default"/>

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


<ejb-jar>
<enterprise-beans>
<entity>
        <ejb-name>fisrtEJB</ejb-name>
        <home>my.java.test.FirstHomeRemote</home>
	<remote>my.java.test.FirstRemote</remote>
	<ejb-class>my.java.test.FirstBean</ejb-class>
	<persistence-type>Container</persistence-type>
	<prim-key-class>java.lang.Object</prim-key-class>
	<reentrant>False</reentrant>
	<abstract-schema-name>MySchema</abstract-schema-name>
	<cmp-field><field-name>name</field-name></cmp-field>
	<cmp-field><field-name>surname</field-name></cmp-field>
	<cmp-field><field-name>mobile</field-name></cmp-field>
	<security-identity><use-caller-identity/></security-identity>
</entity>
</enterprise-beans>
<assembly-descriptor>
....
etc

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

interface:

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

FirstBean:

 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 method: setName(),getName()
etc...


Now let's see the client:


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

    FirstRemote myfirst = (FirstRemote)home.create();
    myfirst.setName("John");


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

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

    Within created table I see that id (autoincrement primary key)
    is added  and Jboss server.log don't return errors, so I can't
figure
    It out this problems..



please help me.
Teo
 




 1 Posts in Topic:
CMP entity bean - javax.ejb.CreateException: Primay key for crea
"rs232" <rs2  2007-02-08 13:01:32 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed Jul 9 6:13:19 CDT 2008.