-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: envers DuplicateMappingException @ManyToMany
PostPosted: Sun May 24, 2009 12:58 pm 
Newbie

Joined: Sat Nov 24, 2007 6:32 pm
Posts: 1
Hi Folks,

I found this very interesting envers project yesterday and stared testing with my current project.
After I configured hibernate and added the annotation @Audited to my classes I startet the application and got this DuplicateMappingException on every @ManyToMany attribute that is refereced from both sides of the relation (The N and the M part).

Does anybody know if this is an issue? I didn't find anything in the forum or the JIRA.

Thanks Mario

PS:

Here is the way I added envers to my Hibernate config:

Code:
          AuditEventListener[] auditEventListener = new AuditEventListener[] {new AuditEventListener()};
          annotationConfiguration.getEventListeners().setPostInsertEventListeners(auditEventListener);
          annotationConfiguration.getEventListeners().setPostUpdateEventListeners(auditEventListener);
          annotationConfiguration.getEventListeners().setPostDeleteEventListeners(auditEventListener);
          annotationConfiguration.getEventListeners().setPreCollectionUpdateEventListeners(auditEventListener);
          annotationConfiguration.getEventListeners().setPreCollectionRemoveEventListeners(auditEventListener);
          annotationConfiguration.getEventListeners().setPostCollectionRecreateEventListeners(auditEventListener);

Here is one part of an problematic attribute mapping:

Code:
@Audited
public class Instruction {
...
   @ManyToMany(fetch = FetchType.LAZY)
   @JoinTable(name = "instruction_asset_classes",
         joinColumns = { @JoinColumn(name = "instruction_id", nullable = false, updatable = false) },
         inverseJoinColumns = { @JoinColumn(name = "asset_class_id", nullable = false, updatable = false) })
   public Set<AssetClass> getAssetClasses() {
      return this.assetClasses;
   }
...
}


Here is the other part of an problematic attribute mapping:

Code:
@Audited
public class AssetClass {
...
   @ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
   @JoinTable(name = "instruction_asset_classes",
         joinColumns = { @JoinColumn(name = "asset_class_id", nullable = false, updatable = false) },
         inverseJoinColumns = { @JoinColumn(name = "instruction_id", nullable = false, updatable = false) })
   public Set<Instruction> getInstructions() {
      return this.instructions;
   }
...
}

Here is the exception:

org.hibernate.DuplicateMappingException: Duplicate class/entity mapping instruction_asset_classes_AUD
at org.hibernate.cfg.Mappings.addClass(Mappings.java:141)
at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:167)
at org.hibernate.cfg.Configuration.add(Configuration.java:702)
at org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:531)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:291)
at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1148)
at org.hibernate.envers.configuration.AuditConfiguration.getFor(AuditConfiguration.java:102)
at org.hibernate.envers.event.AuditEventListener.initialize(AuditEventListener.java:249)
at org.hibernate.event.EventListeners$1.processListener(EventListeners.java:198)
at org.hibernate.event.EventListeners.processListeners(EventListeners.java:181)
at org.hibernate.event.EventListeners.initializeListeners(EventListeners.java:194)
at org.hibernate.cfg.Configuration.getInitializedEventListeners(Configuration.java:1338)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1327)
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:867)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.