2 Replies Latest reply on Oct 26, 2009 3:00 PM by mwilmes

    Problem Joining 3 Tables

    mwilmes

      Hi,

      I have two Entities A and B each with a simple primary key idA and idB. I join them using a third table AB that has a composite primary key using an embedded primary key class ABPk. So far it works fine.

      Now I got another table C with a simple primary key idC involved that has to be joined with AB using another table ABC. So this last table has a composite primary key ABCpk that consists of the parts idC and ABPk which itself consists of idA and idB.

      All composite primary keys use the @Embeddable Annotation and are imbedded using @EmbeddedId similar to what is recommended in https://www.jboss.org/community/wiki/EJB3relationships

      My problem is that on ABC I can't activate the @ManyToOne Annotation that references AB. On deployment this gives me a NullPointerException.

      I am using JBoss 4.2.3.GA with Sun Java 1.6.0.16.

      Thanks
      Martin

        • 1. Re: Problem Joining 3 Tables
          wolfgangknauf

          Hi Martin,

          could you post the relevant snippets of your deployment and also the exception + stacktrace?
          I never tried it with such a nested relationship, so unfortunately I cannot provide you with a quick solution.

          What are your "FetchType" declarations? Probably all LAZY and no EAGER?

          You might find more help is you ask this question in the hibernate forums at https://forum.hibernate.org/index.php . If you find help there, you might update the Wiki article to point at this problem.

          Best regards

          Wolfgang

          • 2. Re: Problem Joining 3 Tables
            mwilmes

            Hi Wolfgang,

            thanks for your answer. I will do as you recommend but that will take some time since I am very busy currently.

            Best regards
            Martin