2 Replies Latest reply on Aug 2, 2010 9:20 AM by John Logan

    How to use multiple entity Inheritance

    John Logan Newbie

      Hy!


      I'd like to user multiple entity Inheritance(like:TABLEPERCLASS,SINGLETABLE) within an entity hierarchy.

                                        -c
                        -B(SINGLE
      TABLE)-
      A(TABLEPERCLASS)-               -D
                        -E
                      
         
      Is it possible?

        • 1. Re: How to use multiple entity Inheritance
          Shervin Asgari Master

          There are lots of examples online on how to do this. Just google JPA inheritance.




          @Entity
          @Inheritance(strategy = InheritanceType.SINGLE_TABLE) // optional annotation as this is default
          @DiscriminatorColumn(name = "apType", discriminatorType = DiscriminatorType.STRING, length = 255)
          @DiscriminatorValue("AP")
          public class ApplicationProcess





          @Entity
          @DiscriminatorValue("APS")
          public class ApplicationProcessScheme extends ApplicationProcess



          • 2. Re: How to use multiple entity Inheritance
            John Logan Newbie
            Thanks, but I want to use DIFFERENT strategies!

            example:

            @Entity
            @Inheritance(strategy = InheritanceType.SINGLE_TABLE)
            public class ApplicationProcess

            @Entity
            @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
            public class ApplicationProcessScheme extends ApplicationProcess