Hi Melanie,

I'm using WebLogic 7.0.1 rather than JBoss, but I would guess that you
need more parameters to jboss:entity-command tag. In the docs I see
jboss:entity-command-attribute. It seems that JBoss isn't even
attempting to create the PK. Perhaps you need to specify *how* it should
do it. For example, here's how I have mine set up:

 * @weblogic:automatic-key-generation
 *      generator-type="ORACLE"
 *      generator-name="user_info_seq"
 *      key-cache-size="10"

This tells WL to use the Oracle sequence "user_info_seq" and grab 10
keys at a time (to minimize DB access). If no one on the list has a
working example, I'd start with the JBoss documentation to see how it
should look in the deployment descriptor. With that information, look in
the .xdt to see what tags XDoclet is putting where.

I hope this is useful. Good luck!

David Harkness
Sony Pictures Digital Networks
(310) 482-4756
 


-----Original Message-----
From: Melanie Roming [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, July 01, 2003 4:31 PM
To: [EMAIL PROTECTED]
Subject: [Xdoclet-user] autoincrement with JBoss


Hi,

I want to create an Entity Bean with an autoincrement primary key, and
tried the code below:

/**
 * @ejb:bean
 *  name="TestEntity"
 *  jndi-name="jndi/TestEntityBean"
 *  type="CMP"
 *  cmp-version="2.x"
 *  view-type="both"
 *  primkey-field="id"
 * @ejb.util generate="physical"
 * @ejb.persistence
 *  table-name="test"
 * @ejb.transaction
 *  type="Required"
 * @jboss.entity-command name="get-generated-keys" 
 * @jboss:create-table true
 **/

public abstract class TestEntityBean implements EntityBean
{

        /**
         [EMAIL PROTECTED]:create-method
         * view-type="local"
         **/

        public java.lang.Long ejbCreate(String text) throws
javax.ejb.CreateException
        {
                setText(text);
                //EJB 2.0 spec says return null for CMP ejbCreate
methods.
                return null;
        }

        /**
         * @ejb.persistent-field
         * @ejb:persistence
         * column-name="text"
         * @ejb:interface-method
         * view-type="local"
         **/
        public abstract void setText(java.lang.String text);

        /**
         * @ejb.persistent-field
         * @ejb:persistence
         * column-name="text"
         * @ejb:interface-method
         * view-type="local"
         **/
        public abstract java.lang.String getText();

        /**
         * @ejb.persistent-field
         * @ejb:persistence
         * column-name="id"
         * @ejb:interface-method
         * view-type="local"
         * @ejb:pk-field
         **/
        public abstract void setId(java.lang.Long id);

        /**
         * @ejb.persistent-field
         * @ejb:persistence
         * column-name="ID"
         * @ejb:interface-method
         * view-type="local"
         * @ejb:pk-field
         * @jboss.persistence autoincrement="true"
         **/
        public abstract java.lang.Long getId();


If I try to insert something in the table with this create Method I get
an error:

01:00:12,092 ERROR [TestEntity] Could not create entity
java.sql.SQLException: ERROR: ExecInsert: Fail to add null value in not
null attribute id

What is wrong?

Thanks Melanie


-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100006ave/direct;at.asp_061203_01/01
_______________________________________________
xdoclet-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-user


-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100006ave/direct;at.asp_061203_01/01
_______________________________________________
xdoclet-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-user

Reply via email to