4 Replies Latest reply on Jun 23, 2009 7:24 AM by Adam Warski

    Discriminator-value while loading assocation

    Amar Singh Newbie

      Envers doesn't take into account the discriminator value while loading assocation. For eg. if a class has many-to-one mapping to class which has discriminator value, envers doesn't take into account the discriminator value while loading the class. It simply refers to the "class" defined in mapping. I

      In code ToOneIdMapper.java uses "referencedEntityName" and the ReflectionTools.loadClass(...) always returns the class type defined in mapping.

      Is this a bug ?

        • 1. Re: Discriminator-value while loading assocation
          Adam Warski Master

          Hello,
          I assume that the association's target is to a subclass? If so, then it's a bug :)
          Adam

          • 2. Re: Discriminator-value while loading assocation
            Przemysław Wojewódka Newbie

            Hi,

            So that's a bug. Adam do you need any futher information?

            Is there any temp solution for this issue?


            I have SingleTable inheritance scenario:

            @Entity
            @Audited
            public abstract class A() {}
            
            @Entity
            @Audited
            public class B extends A() {}
            
            @Entity
            @Audited
            public class C extends A() {}
            


            and class with association:

            @Entity
            @Audited
            public class D() {
            private A a;
            
             @OneToOne(cascade = {MERGE, PERSIST, REFRESH}, fetch = FetchType.EAGER)
             @Fetch(FetchMode.JOIN)
             @NotNull
             public getA() {
             return a;
             }
            
            }


            In DB all is OK, but when I get audited D entity I get only access to A "interface" (what refer to first post) even though target and querries are getting representation of subclasses (B,C).

            Any solution recomended? Thanks in advance!

            best regards

            • 3. Re: Discriminator-value while loading assocation
              Przemysław Wojewódka Newbie

              Hi,

              So that's a bug. Adam do you need any futher information?

              Is there any temp solution for this issue?


              I have SingleTable inheritance scenario:

              @Entity
              @Audited
              @DiscriminatorColumn(name = "type")
              public abstract class A() {}
              
              @Entity
              @Audited
              
              @DiscriminatorValue("B")
              public class B extends A() {}
              
              @Entity
              @Audited
              @DiscriminatorValue("C")
              public class C extends A() {}
              


              and class with association:

              @Entity
              @Audited
              public class D() {
              private A a;
              
               @OneToOne(cascade = {MERGE, PERSIST, REFRESH}, fetch = FetchType.EAGER)
               @Fetch(FetchMode.JOIN)
               @NotNull
               public getA() {
               return a;
               }
              
              }


              In DB all is OK, but when I get audited D entity I get only access to A "interface" (what refer to first post) even though target and querries are getting representation of subclasses (B,C).

              Any solution recomended? Thanks in advance!

              best regards

              • 4. Re: Discriminator-value while loading assocation
                Adam Warski Master

                Hello,

                then please create a bug in Jira, preferrably with a testcase. You can also try looking at the source code, maybe you'll find a fix :)

                Adam