14 Replies Latest reply on Apr 29, 2009 9:16 AM by adamw

    @ManyToMany relations. Should it work?

      Hi,

      I have problem with @ManyToMany relation.

      Here is example of my code:

      @Entity
      @Audited
      @Table(name = "org_entity")
      @Inheritance(strategy = InheritanceType.JOINED)
      public abstract class AbstractOrgEntity implements Serializable {
      ...
       /**
       * ID.
       */
       @Id
       @GeneratedValue(strategy = GenerationType.AUTO)
       private Long id;
      
       @ManyToMany(fetch = FetchType.LAZY)
       @JoinTable(
       name = "org_ent_app",
       joinColumns = { @JoinColumn(name = "org_entity_id") },
       inverseJoinColumns = { @JoinColumn(name = "application_id") }
       )
       private List<Application> applications;
      ...
      


      @Entity
      @Audited
      @Table(name = "application")
      public class Application implements Serializable {
      ...
       @Id
       @GeneratedValue(strategy = GenerationType.AUTO)
       private Long id;
      
       @ManyToMany(mappedBy = "applications")
       private Set<AbstractOrgEntity> orgEntities;
      ...
      


      I have these tables in DB:
      application
      org_entity
      org_ent_app

      and audited tables

      application_aud
      org_entity_aud
      org_ent_app_aud

      When I assign application to org_entity subclass and store it there is record in org_ent_app table but there is no record in org_ent_app_aud table. Am I missing something or this is not supported in Envers? I use Enveres 1.2.0.GA-hibernate-3.3.

      jrv