3 Replies Latest reply on Oct 15, 2004 4:48 AM by triathlon98

    jbosscmp-jdbc.xml syntax

    tkvarenes

      I'm trying to deploy an application with alter-table set, to update the tables in my database, but I get this error message:

      ALTER TABLE only allows columns to be added that can contain nulls or have a DEFAULT definition specified. Column 'ol_version' cannot be added to table 'STOCK' because it does not allow nulls and does not specify a DEFAULT definition.

      The definition for optimistic locking in my jbosscmp-jdbc.xml look like this:

      <optimistic-locking>
      <version-column/>
      <field-name>versionField</field-name>
      <column-name>ol_version</column-name>
      <jdbc-type>INTEGER</jdbc-type>
      <sql-type>INTEGER</sql-type>
      </optimistic-locking>


      How can I define a default value of e.g 0?

      /TK

        • 1. Re: jbosscmp-jdbc.xml syntax
          triathlon98

          This seems to be a database specific issue.

          Try looking at/editing the conf/standardjbosscmp-jdbc.xml file. You can either change the alter table template (also see details in the wiki), or you can change the default typemappings for your database to include default values for some types (probably numeric types).

          Joachim

          • 2. Re: jbosscmp-jdbc.xml syntax
            tkvarenes

            There was nothing about "add column" in the MS SQL section so I tried to add

            <add-column-template>ALTER TABLE ?1 ADD COLUMN ?2 ?3</add-column-template>

            but I got an error saying:
            Invalid XML: file=file:/.../standardjbosscmp-jdbc.xml

            Any Ideas?



            • 3. Re: jbosscmp-jdbc.xml syntax
              triathlon98

              The order of the items is important.

              If nothing was in the file, then the default template is used, so just adding this template will not be enough as it still doesn't set any of the constraints on the fields.

              Unfortunately my knowledge of MS SQL is insufficient to give specific help.

              However, I constantly use this for feature for the Firebird database, and have changed the default type mappings to include default values to prevent similar issues. You may have a look there.

              Once you have got working changes, please submit the modifications as a bug report.

              Thanks
              Joachim