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

    How to use multiple entity Inheritance

    logan

      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
          cash1981

          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
            logan
            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