2 Replies Latest reply on Jun 12, 2003 6:37 AM by ittay

    mysql and default values

    ittay Newbie


      I've created a table that contains some columns with default value and 'not null'. e.g., 'foo bigint(20) not null default 0'.

      My bean has a 'public abstract Integer getFoo()' mapped to that column (and table). When I create the bean, I get an error from mysql. I look at the logs and see that JBoss tries to insert a new record with null for 'foo'. How can I tell JBoss (or mysql) to use the default values? (I can, of course, set the values to the default at ejbCreate(), but I wish for the db schema to control them)

      Thank you,

        • 1. Re: mysql and default values
          null null Newbie

          try to change your CMP definition:

          here is how I did it:
          <ent ity>
          <sql-type>TIMESTAMP WITHOUT TIME ZONE DEFAULT now()</sql-type>

          • 2. Re: mysql and default values
            ittay Newbie

            thanx for the help, and i'll try this tip, but isn't there a way of telling jboss to just not insert null values (or, at least, just tell it that a certain value has a default in the db).