2 Replies Latest reply on Jul 15, 2003 8:29 AM by rogera

    autoincrement jboss 3.2.1 mysql 4.1

    gast73

      Hello
      I configured Jboss 3.2.1 to use mysql 4.1 as DefaultDS
      Everything seems to work.
      Then I tried to use autoincrement feature following mony posts on yhis forum.

      So I changed standardjbosscmp-jdbc.xml:


      java:/DefaultDS
      <datasource-mapping>mySQL</datasource-mapping>

      <create-table>true</create-table>
      <remove-table>false</remove-table>
      <read-only>false</read-only>
      <time-out>300</time-out>
      <pk-constraint>true</pk-constraint>
      <fk-constraint>false</fk-constraint>
      <row-locking>false</row-locking>
      <preferred-relation-mapping>foreign-key</preferred-relation-mapping>
      <read-ahead>
      on-load
      <page-size>1000</page-size>
      <eager-load-group>*</eager-load-group>
      </read-ahead>
      <list-cache-max>1000</list-cache-max>

      <entity-command name="default"/>



      .....

      removing unknown-pk entry

      Then I wrote an entity bean using xdoclet:

      /**
      * @jboss.unknown-pk
      * class="java.lang.Integer"
      * column-name="id"
      * jdbc-type="INTEGER"
      * sql-type="INTEGER"
      * auto-increment="true"
      * @jboss.entity-command name="mysql-get-generated-keys"
      */

      /**
      *
      * @ejb.pk-field
      * @ejb.persistent-field
      * @ejb.interface-method
      *
      * @ejb.persistence column-name="id"
      *
      * @jboss.auto-increment
      */
      public abstract Integer getId();

      /**
      */
      public abstract void setId(Integer id);



      It builds and deploys fine.
      But when I call a create method from the bean home
      I retrieve the bean interface and Calling getId() method I get a ClassCastException.
      I tried a lot of different configurations. I tried to remove the unknown-pk entry. Put it back in standardjbosscmp-jdbc.xml.
      Set in standardjbosscmp-jdbc.xml the entity-command to use it as default.
      I use JConnector 3.0.8 for mysql.
      Any advice?

        • 1. Re: autoincrement jboss 3.2.1 mysql 4.1
          gast73

          Changed the pk from java.lang.Integer to java.lang.Long. Everything works fine.
          It seems that mysql-get-generated-keys returns a Long and not a Integer.

          • 2. Re: autoincrement jboss 3.2.1 mysql 4.1
            rogera

            Not strictly on your point but:
            Have you tried to run the 3.2.1 testsuite against the mysql 4.1 ds? I tried this configuration and it fails many of the CMP tests and tests in other suites too.
            There are a number of folks on these forums who have had and are having trouble with MySql on 3.2.1.
            I can get things to 'work', but whether it is robust and working 'properly', remains at another matter.