[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-4072?page=c...
]
david sinclair commented on HHH-4072:
-------------------------------------
Adam, sorry this was a false alarm. It has to do with the fact that the
MappedSuperclass's ManyToMany specifies a name for the JoinTable. Envers is correctly
trying to create tables for each subclass but since it is the same name for each subclass,
it trys to create dups. Removing the name from the join table makes hibernate creates
separate join tables for each subclass and envers creates one for each.
This can be marked as invalid. Sorry again.
dave
ManyToMany with single table inheritance fails when multiple
subclasses
-----------------------------------------------------------------------
Key: HHH-4072
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-4072
Project: Hibernate Core
Issue Type: Bug
Components: envers
Affects Versions: 3.3.2
Environment: Windows XP, Java 1.6
Reporter: david sinclair
Priority: Critical
I have a base entity named BusinessSoftwareMatrixElement declare as such
@Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "software_type", discriminatorType =
DiscriminatorType.STRING)
@DiscriminatorValue("Software")
@Audited
BusinessSoftwareMatrixElement ...{ }
I then have a subclass of BusinessSoftwareMatrixElement that is a mapped super class
which defines a many to many relationship.
@MappedSuperclass
@Audited
public abstract class BusinessOSProcessServiceMatrixElement extends
BusinessSoftwareMatrixElement {
private Set<BusinessOSMatrixElement> applicableOperatingSystems = new
HashSet<BusinessOSMatrixElement>();
@ManyToMany(fetch = FetchType.LAZY, cascade = {CascadeType.REMOVE, CascadeType.REFRESH
}, targetEntity = BusinessOSMatrixElement.class)
@JoinTable(name="matrix_elements_procserv_aos",
joinColumns=@JoinColumn(name="sw_guid"),
inverseJoinColumns = @JoinColumn(name="os_guid"))
public Set<BusinessOSMatrixElement> getApplicableOperatingSystems() {
return applicableOperatingSystems;
}
}
There are then to subclasses that add no new fields, only different discriminators
@Entity
@DiscriminatorValue("Database")
@Audited
public class BusinessDBMatrixElement extends BusinessOSProcessServiceMatrixElement {
@Entity
@DiscriminatorValue("Application")
@Audited
public class BusinessAppMatrixElement extends BusinessOSProcessServiceMatrixElement {
Running the ant task to create the DDL results in an exception being thrown for that many
to many table.
Caused by: org.hibernate.DuplicateMappingException: Duplicate class/entity mapping
matrix_elements_procserv_aos_AUD
at org.hibernate.tool.ant.HibernateToolTask.reportException(HibernateToolTask.java:226)
at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:189)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
at org.apache.tools.ant.Task.perform(Task.java:364)
at org.apache.tools.ant.Target.execute(Target.java:341)
at
org.apache.maven.plugin.antrun.AbstractAntMojo.executeTasks(AbstractAntMojo.java:108)
... 24 more
Caused by: org.hibernate.DuplicateMappingException: Duplicate class/entity mapping
matrix_elements_procserv_aos_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:716)
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:1162)
at
org.hibernate.envers.configuration.AuditConfiguration.getFor(AuditConfiguration.java:102)
at
org.hibernate.envers.ant.AnnotationConfigurationTaskWithEnvers.doConfiguration(AnnotationConfigurationTaskWithEnvers.java:38)
at org.hibernate.tool.ant.ConfigurationTask.getConfiguration(ConfigurationTask.java:55)
at
org.hibernate.tool.ant.HibernateToolTask.getConfiguration(HibernateToolTask.java:302)
at
org.hibernate.tool.ant.Hbm2DDLExporterTask.createExporter(Hbm2DDLExporterTask.java:51)
at org.hibernate.tool.ant.ExporterTask.execute(ExporterTask.java:39)
at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:186)
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira