Hi, Thanks for the reply.  Could you elaborate a little on how to setup the
PK to be generated.  Do you mean setup by dbms or setup via the ejb
configuration (xml)?  Please continue, and thanks!

Here is the entity bean ejbCreate:
        public accountHolderBeanPK ejbCreate(String theEmailAddress,
                String theEmailTypeCd,
                String theAccountPassword) throws CreateException
        {
                setAccountRoleId(new Integer(1));
                setEmailAddress(theEmailAddress);
                setEmailTypeCd(theEmailTypeCd);
                setAccountPassword(theAccountPassword);
                return null;
        }

Here is the local home interface:
public homebrew.ejb.interfaces.accountHolderBeanLocal
create(java.lang.String theEmailAddress,
java.lang.String theEmailTypeCd,
java.lang.String theAccountPassword) throws javax.ejb.CreateException;

Here is a portion of the stack trace:
javax.ejb.CreateException: Could not create entity:java.sql.SQLException:
Try to insert null into a
non-nullable column in statement [INSERT INTO ACCOUNT_HOLDER (account_id,
account_role_id, email_add
ress, email_type_cd, account_password, fname, ssn) VALUES (NULL, 1,
'[EMAIL PROTECTED]',
 'BUS', 'mypassword', NULL, NULL)]
        at
org.jboss.ejb.plugins.cmp.jdbc.JDBCCreateEntityCommand.insertEntity(JDBCCrea
teEntityComma
nd.java:199)
        at
org.jboss.ejb.plugins.cmp.jdbc.JDBCCreateEntityCommand.execute(JDBCCreateEnt
ityCommand.ja
va:131)
        at
org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.createEntity(JDBCStoreManage
r.java:527)
        at
org.jboss.ejb.plugins.CMPPersistenceManager.createEntity(CMPPersistenceManag
er.java:253)
        at
org.jboss.resource.connectionmanager.CachedConnectionInterceptor.createEntit
y(CachedConne
ctionInterceptor.java:270)
        at
org.jboss.ejb.EntityContainer.createLocalHome(EntityContainer.java:580)

As you can see, it looks like the container is trying to just insert a null
into the account_id primary key column.  If I use straight SQL and omit the
account_id from the insert, it works just fine.

Matt

-----Original Message-----
From: Alexey Loubyansky [mailto:[EMAIL PROTECTED]
Sent: Thursday, May 15, 2003 2:19 AM
To: Jeremy Boynes
Subject: Re[2]: [JBoss-user] Entity ejbCreate Parameter


If the pk field is setup to be generated then you don't have to do
anything in ejbCreate and just return null.

alex

Thursday, May 15, 2003, 1:35:38 AM, Jeremy Boynes wrote:

JB> With CMP you have two basic choices:

JB> 1) Have a utility class fetch the values from the sequence and then pass
JB> them
JB>    to the create method.

JB> 2) Use an unknown pk model where the EJB leaves the definition of the
JB> primary
JB>    key to the Container (CMP). In this case you don't pass anything to
JB> create
JB>    and you need to configure CMP to generate the key for you.

JB> With 3.2.1 and earlier we have a PkSQL generator that will issue an SQL
JB> statement to fetch the key value before performing the insert. The SQL
would
JB> be something like "SELECT MYSEQ.NEXTVAL FROM SYS.DUAL" where MYSEQ is
your
JB> sequence name. The type of the generated key (as returned by
JB> getPrimaryKey()) is likely to be BigDecimal

JB> With 3.2.2beta we have a specialized key generator for Oracle that uses
an
JB> INSERT ... RETURNING statement to perform the insert and return the
JB> generated key in a single operation. This also uses the normal cmp
binding
JB> code so the type of the PK may be specified (e.g. as a Long or Integer).
JB> This is only in the CVS branch so see standardjbosscmp-jdbc.xml and the
JB> jbosscmp-jdbc.xml file for the keygen testcase for details.

JB> Jeremy

>> -----Original Message-----
>> From: [EMAIL PROTECTED]
>> [mailto:[EMAIL PROTECTED] Behalf Of Hanson,
>> Matthew
>> Sent: Wednesday, May 14, 2003 1:49 PM
>> To: '[EMAIL PROTECTED]'
>> Subject: [JBoss-user] Entity ejbCreate Parameter
>>
>>
>> Hi--
>>
>> If my cmp entity bean has a primary key column that is back in Oracle (or
>> whatever database) by an auto-incremented integer datatype, how should I
>> code the ejbCreate method.  Do I need to pass int or Integer as the
>> parameter?  Or does the j2ee spec dictate that the insert must produce
the
>> primary key for me based on the table attributes (i.e., no
>> parameters needed
>> for ejbCreate).
>>
>> I'm a little confused, so if someone could just get me started, I
>> would find
>> that a great help.
>>
>> Thanks!
>> Matt Hanson



-------------------------------------------------------
Enterprise Linux Forum Conference & Expo, June 4-6, 2003, Santa Clara
The only event dedicated to issues related to Linux enterprise solutions
www.enterpriselinuxforum.com

_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user


-------------------------------------------------------
Enterprise Linux Forum Conference & Expo, June 4-6, 2003, Santa Clara
The only event dedicated to issues related to Linux enterprise solutions
www.enterpriselinuxforum.com

_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to