2 Replies Latest reply on Jul 13, 2003 7:44 AM by yongjunzheng

    ejb auto-increment

    sys user Master

      Has anyone had success getting their EntityBean's to function correctly when doing an entity.create(name); and then being able to access the id of the newly created record when using the auto-increment functionality of your db (specifically, I'm using mysql to automagically generate the primary-key id fields for my tables)?

      I'm getting the following exception/message - see attached TransactionRolledBackException.txt

      I'm using jboss3.2.0 cmp2.0 and ejb2.0. I'm also using xdoclet1.2beta3 to generate the deployment desriptors for my beans.

      Thanks for any help in advance.
      -Jason

        • 1. Re: ejb auto-increment
          Robert de Lorimier Newbie

          It works fine when I do it. I a, using mysql, xdoclet 1.1.2, and jboss 3.2.0

          You need to have the primary key set to an auto incrementing field:

          CREATE TABLE FOO (
          ID int NOT NULL auto_increment PRIMARY KEY,
          ...

          * @ejb:bean
          ...
          * type="CMP"
          * schema="FOO"
          * primkey-field="id"

          • 2. Re: ejb auto-increment
            yongjunzheng Newbie

            to rodelor,

            I also have the same problem as jchilders. I can not get my cmp2.0 EntityBean work correctly with a auto-increment field.

            I am using mssql2000 server, the table definition as following:

            create table Test(
            id numeric(10,0) identity not null primary key,
            name char(10) not null
            )


            Could you give me a whole sample to solve the problem? My Email is yongjunzheng@163.com

            Thank you in advance.