1 Reply Latest reply on Aug 4, 2006 5:05 AM by Alex

    Custom ejbCreate() generates bad INSERT-Statement (4.0.2)

    Alex Newbie

      Hi

      Given the following EntityBean:

      Person
      -------
      Name
      Gender
      Age (ORACLE DEFAULT 18)
      


      and the following custom ejbCreate() call:

      ejbCreate("Alex","m")


      why is the generatet INSERT - Statement like this:

      INSERT INTO PERSON(NAME, GENDER, AGE) VALUES ("Alex","m",NULL)


      when it should be:

      INSERT INTO PERSON(NAME, GENDER) VALUES ("Alex","m")


      The Oracle Database could insert the DEFAULT Value by itself but JBoss attaches the NULL value. Can someone confirm this or link me to a documentation? Thanks.

      --
      Alex

        • 1. Re: Custom ejbCreate() generates bad INSERT-Statement (4.0.2
          Alex Newbie

          I found something in the EJB 2.0 spec 14.1.2

          The Container must ensure that the values of the container-managed fields are set to the Java language
          defaults (e.g. 0 for integer, null for pointers) prior to invoking an ejbCreate(...) method on an
          instance.


          I also have to correct my prior post. NUMBER-Columns are initialized with 0, while VARCHAR2-Columns with NULL. So the INSERT for my example:

          ejbCreate("Alex", "m")

          translates to

          INSERT INTO PERSON(NAME, GENDER, AGE) VALUES ("Alex","m", 0)


          Unfortunatly I couldn't find anything that manipulates the generated INSERT-Statements.