1 Reply Latest reply on Feb 22, 2004 12:31 PM by Rafal Kedziorski

    mySQL - auto_increment

    Klaus Kaal Newbie

       

      "kkaal" wrote:
      "kkaal" wrote:
      "kkaal" wrote:
      "kkaal" wrote:
      I have checked so many documents now, but getting more and more confused:

      I am using JB3.2.3, MySQL4.0, Eclipse and xDOCLET

      Created a table:

      create table mytest (
      id Integer not null primary key auto_increment,
      test Char(20) )

      Could anybody tell me how exactly, I have to create a CMP Bean with xDoclet to make the auto-increment work correctly?

      You really would save me some sleeples nights :-)

      Thanks

      Klaus


        • 1. Re: mySQL - auto_increment
          Rafal Kedziorski Novice

          try this:

          /**
          * ...
          *
          * @jboss.entity-command
          * name = "mysql-get-generated-keys"
          *
          */
          public abstract class Setting_2_UserBean extends AbstractEntityBean implements EntityBean {
          /**
          * Gets the setting_2_user_id attribute of the Setting_2_UserBean object
          *
          * @return The setting_2_user_id value
          * @ejb.pk-field
          *
          * @ejb.persistence
          * column-name = "setting_2_user_id"
          * sql-type = "setting_2_user_id"
          *
          * @jboss.persistence
          * auto-increment = "true"
          *
          * @ejb.interface-method
          * view-type = "local"
          *
          */
          public abstract Long getSetting_2_user_id();


          /**
          * Sets the setting_2_user_id attribute of the Setting_2_UserBean object
          *
          * @param setting_2_user_id The new setting_id value
          */
          public abstract void setSetting_2_user_id(Long setting_2_user_id);

          ...
          }

          You have to define

          @jboss.entity-command
          name = "mysql-get-generated-keys"
          on class level.

          and

          @jboss.persistence
          auto-increment = "true"

          on method level.

          Rafal