7 Replies Latest reply on Jan 22, 2006 12:16 PM by amitguz

    Inheritance in EJB3

    feint

      The tutorial and EJB3 spec docs don't give a lot of information on inheritance and the strategies. Specifically, is it possible to change inheritance strategies part way through the inheritance tree? i.e.

      ClassB inherits from ClassA using JOINED
      ClassC inherits from ClassB using TABLE_PER_CLASS
      ClassD inherits from ClassC using SINGLE_TABLE

      or does my entire heirarchy need to use the same strategy?
      It is not clear from the example since the root class implements the same strategy as the class that inherits from it.

      Thanks for any insights..

        • 1. Re: Inheritance in EJB3
          bill.burke

          I don't think so. I'll need to consult the Hibernate docs.

          • 2. Re: Inheritance in EJB3
            feint

            Just to post the result:
            I looked in the hibernate docs and talked to the people on the message boards. Yes Hibernate can do it. Unfortunately, EJB3 can't due to a few lines in the persistance spec. The spec essentially says that each inheritance heirarchy has only 1 strategy and that it is normally declared at the root node of the inheritance tree.

            I've submitted a request to the EJB3 spec working group to change it to be at least optional to support multiple persistence strategies in a single tree...

            • 3. Re: Inheritance in EJB3
              deb

              For the record, I would also like to see this particular restriction removed from the EJB3 spec. I can definitely see using multiple strategies as being useful (and would've been surprised if Hibernate really didn't support that).

              • 4. Re: Inheritance in EJB3
                bill.burke

                It looks like this restriction may be removed from the spec. Stay tuned for the Public Draft

                • 5. Re: Inheritance in EJB3
                  epbernard

                   

                  "deb" wrote:
                  For the record, I would also like to see this particular restriction removed from the EJB3 spec. I can definitely see using multiple strategies as being useful (and would've been surprised if Hibernate really didn't support that).

                  Swithcing of inheritance in the middle might lead to very complex situations. This is not as trivial as few lines in a spec ;-)
                  Hibernate3 can do it, but H2 couldn't. People used to live with that wo much trouble.

                  • 6. Re: Inheritance in EJB3
                    feint

                    In the 02/07/05 version of the spec, the text has been changed to the following:
                    " Support for the combination of inheritance strategies will be addressed in a future release of this specification."

                    Stay tuned...
                    DCM

                    • 7. Re: Inheritance in EJB3
                      amitguz

                      Are there any news regrading this issue?
                      Does the current ejb3 which comes with JBOSS 4.0.3 support different inheritance in the same tree?