1 2 Previous Next 18 Replies Latest reply on Dec 13, 2008 8:19 AM by adamw Go to original post
      • 15. Re: Envers future...

        Success and a follow up...

        I promoted the embedded object to an entity and added @AuditJoinTable. I did not need to change @CollectionOfElements to @OneToMany and I did not need to add @JoinColumn.

        ...
        @CollectionOfElements
        @JoinTable(name="systemcomponent",
        joinColumns = @JoinColumn(name="system_id"),
        inverseJoinColumns = @JoinColumn(name="component_id") )
        @AuditJoinTable(name="systemcomponent",
        inverseJoinColumns = @JoinColumn(name="component_id") )
        private Set components;
        ...

        However, I also had to change my mapped super class to an entity and use the "table per class" inheritance type. This seemed to be the main part of the problem.

        Thanks for all your work on Envers, and sorry for hijacking your thread.

        Dave

        • 16. Re: Envers future...
          adamw

          Hello,

          yes, you're right, collections of components aren't yet supported. When you convert your collection to an entity, it should work - but then you need to use @OneToMany.

          Do you get an exception when using @OneToMany? If yes, then it's probably a bug - please create a test case and post it to JIRA :)

          --
          Thanks,
          Adam

          • 17. Re: Envers future...

            The annotation @CollectionOfElements seems to work when the "many" object is an entity, without using the @OneToMany annotation. -- I am doing unit tests today to verify this.

            I don't get an exception using @OneToMany, but our code already uses @CollectionOfElements; and since Hibernate has indicated @CollectionOfElements is a replacement for @OneToMany, we are going to try to stick with it.

            ---

            After review the logs, the primary error I found happened when I made the super class an @MappedSuperclass instead of an entity.

            Am I correct in stating that Envers doesn't handle one to many relations when using @MappedSuperclass inheritance, or do you want me to post this to JIRA?

            • 18. Re: Envers future...
              adamw

              Hello,

              @CollectionOfElements is a replacement for @OneToMany only in case of a persistent collection of components or "core types". See here: http://www.hibernate.org/hib_docs/annotations/reference/en/html/entity.html#entity-hibspec-collection-extratype, section 2.4.6.2.5. So it shouldn't be used in case of entities.

              So you get an error when using @OneToMany in a @MappedSuperclass? This should work, and if you are recieveing any errors when trying to do so, please post a JIRA with a testcase.

              --
              Adam

              1 2 Previous Next