2 Replies Latest reply on Sep 24, 2004 5:30 PM by stud

    Is it possible to do relations on generated/unknown primary

    stud

      Hi all,
      perhaps this time someone will reply, my question is wheter it is possible in JBoss to do a container managed relation on an entitiy which has an unknown primary key (Section 10.8.3 of the EJB 2.0 Spec).

      I never got it to work so I begin to believe that JBoss can't handle that.

      Is this correct?

      Greetings,
      stud

        • 1. Re: Is it possible to do relations on generated/unknown prim

          Yes this is possible, the difficulty is that with several of the databases when the foreign key column is created it is set to the same type as the primary key column which may not allow for null. So you either have to specify the sql type to use which in the case of postgres I used INTEGER for the foreign key while the primary key is of type SERIAL. The other option which I have not used if you want the foreign key to be non-null is to set the relation in the post create methods and then there is a flag you need that says to not save to the DB until after the post create. I do not remember what the flag is becasue I have not used it but I have seen numerous postings that discuss its use.

          Hope this helps,
          Mark

          • 2. Re: Is it possible to do relations on generated/unknown prim
            stud

            Great that it's possible, however I always got deployment exceptions about nonexistent fields...

            Perhaps you can have a look at my earlier post and give me a hint on what I have done wrong.

            http://jboss.org/index.html?module=bb&op=viewtopic&t=54267


            Thanks,
            stud