0 Replies Latest reply on Jan 13, 2005 9:23 AM by uschmid

    setting default-values from mySQL in EntityBeans

    uschmid Newbie


      I'm working with JBoss 3.2.3, EntityBeans (CMP) and mySQL.

      I have a table defined in my mySQL-db which has a CHAR(1)-field called "flag", with the default-value "o". My EntityBean maps that table.

      My problem is now, that whenever I create a new instance of that table as an EntityBean-instance and leave the field "flag" open, that field in the mySQL db doesn't get the value = "o", but NULL.
      What do I have to change to let my EntityBean set the default-value in the db instead of NULL whenever the field is not set. I don't want to check for NULL and then set "o" in my EntityBean.

      I tried to define field "flag" as NOT NULL in the db. But then I get a CreateException. -> Field flag must not be null

      I thought this is maybe a common problem, but I couldn't find anything in this forum.

      Help would be appreciated!