2 Replies Latest reply on Oct 1, 2002 3:00 PM by Alexey Loubyansky

    autonumber table problem, it kept removed when server shut d

    liu qiang Newbie

      Hi! I have a problem using autonumber table. I found everytime I shutdown the Jboss server, the autonumber table is removed, But I want it NOT removed.
      In my jbosscmp-jdbc.xml file, I set <remove-table> as false, and I found all the tables I created was kept unremoved when I shut down the server(This is what I want), except the autonumber table. I also use the jaws.xml, and set the following in jaws.xml, but it doesnot help at all. The autonumber table still got removed when I shut down the server. Does anyone know
      the solution of this?

      My jaws.xml:

      jaws>
      MSSQLDS
      <type-mapping>MS SQLSERVER2000</type-mapping>

      <enterprise-beans>


      <ejb-name>AutoNumberEJB</ejb-name>
      <table-name>autonumber</table-name>
      <remove-table>false</remove-table>


      </enterprice-beans>



      My jbosscmp-jdbc.xml part is as follows:

      <jbosscmp-jdbc>

      java:/MSSQLDS
      <datasource-mapping>MS SQLSERVER2000</datasource-mapping>
      <create-table>true</create-table>
      <remove-table>false</remove-table>
      <pk-constraint>true</pk-constraint>
      <preferred-relation-mapping>foreign-key</preferred-relation-mapping>

      <enterprise-beans>


      <ejb-name>AutoNumberEJB</ejb-name>
      <table-name>autonumber</table-name>

      <cmp-field>
      <field-name>name</field-name>
      <column-name>name</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>value</field-name>
      <column-name>value</column-name>
      </cmp-field>

      </enterprise-beans>
      .....
      </jbosscmp-jdbc>

        • 1. Re: autonumber table problem, it kept removed when server sh
          liu qiang Newbie

          This is my mistake, forget this one.

          • 2. Re: autonumber table problem, it kept removed when server sh
            Alexey Loubyansky Master

            If you are with JBoss-3.X then drop jaws.xml.
            What are trying to achieve?
            What field is the primary key?
            Is the field that is the primary key is a cmp field also?

            You are going the wrong way. It won't work in this way. You should consider unknown primary key setup. Currently, for MSSQL you can use such constructs:

            <!-- using sequence table -->
            <unknown-pk>
            <unknown-pk-class>java.lang.Integer</unknown-pk-class>
            <column-name>genid</column-name>
            <jdbc-type>INTEGER</jdbc-type>
            <sql-type>INTEGER</sql-type>
            </unknown-pk>
            <entity-command name="pk-sql">
            SELECT SEQ_2279_1.nextval FROM DUAL
            </entity-command>

            or

            <!-- using UUIDKeyGenerator -->
            <unknown-pk>
            <unknown-pk-class>java.lang.String</unknown-pk-class>
            <column-name>genid</column-name>
            <jdbc-type>VARCHAR</jdbc-type>
            <sql-type>VARCHAR(32)</sql-type>
            </unknown-pk>
            <entity-command name="key-generator"
            class="org.jboss.ejb.plugins.cmp.jdbc.JDBCKeyGeneratorCreateCommand">
            UUIDKeyGeneratorFactory
            </entity-command>

            This will work only with Branch_3_2 and HEAD.

            Auto-increment is currently supported only for MySQL. You can help us to add support for MSSQL autonumber by providing 'CREATE TABLE' SQL statement that sets up a table with autonumber'ed field.

            But I agree it's strange that the table is removed. I use MySQL and don't see it.