2 Replies Latest reply on Sep 12, 2002 12:12 PM by aeiler

    How to make ForeignKey Nullable

    lkmanda

      Can some one tell me how to make Foreign key Nullable.

      I have a foreign Key type Integer and whenever i try to insert value. it gives me an Exception " column cannot be null". as for CMR fields cannot be set untill EjbPostCreate in Ejb and JBoss sends to database before ejbPostcreate() method and tries to insert Null in foreignKey field.


      Ur response appreciated.
      Thanks.
      Leela


        • 1. Re: How to make ForeignKey Nullable
          dsundstrom

          Foreign key fields are not generated with a "not null" constraint. What database are you using? It may be assuming that fks should be not null. Are you allowing JBoss to generate the tables for you.

          • 2. Re: How to make ForeignKey Nullable
            aeiler

            I have run into a problem where the tables that JBoss generates use "not null" fields for foreign key fields. When I edit the database manually to allow null fields, everything works like a charm. Am I screwing up the configuration somewhere?

            I'm using...
            JBoss 3.0.2
            Sybase 12.5 (jConnect 5.5 JDBC Driver)
            sybase-service.xml file provided in docs/examples/jca