[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-3633?page=c...
]
Mark Derricutt commented on HHH-3633:
-------------------------------------
The problem is triggered when an entity include:
private CountryGeo countryGeo;
@ManyToOne
@JoinColumn(table = "postal_address", name = "country_geo_id",
referencedColumnName = "geo_id", nullable = true, insertable = true, updatable =
true)
@Versioned
public CountryGeo getCountryGeo() {
return countryGeo;
}
public void setCountryGeo(CountryGeo countryGeo) {
this.countryGeo = countryGeo;
}
On the envers side of things,
org.hibernate.envers.configuration.metadata.AuditMetadataGenerator#generateFirstPass only
stores a reference to Geo in its entitiesConfigurations map, so the CountryGeo reference
is not found.
As an initial experiment, I tried modifying envers to also store references to the
subclasses:
Index:
src/main/java/org/hibernate/envers/configuration/metadata/AuditMetadataGenerator.java
===================================================================
---
src/main/java/org/hibernate/envers/configuration/metadata/AuditMetadataGenerator.java (revision
15671)
+++
src/main/java/org/hibernate/envers/configuration/metadata/AuditMetadataGenerator.java (working
copy)
@@ -41,11 +41,7 @@
import org.hibernate.MappingException;
import org.hibernate.cfg.Configuration;
-import org.hibernate.mapping.Collection;
-import org.hibernate.mapping.Join;
-import org.hibernate.mapping.PersistentClass;
-import org.hibernate.mapping.Property;
-import org.hibernate.mapping.Value;
+import org.hibernate.mapping.*;
import org.hibernate.type.CollectionType;
import org.hibernate.type.ManyToOneType;
import org.hibernate.type.OneToOneType;
@@ -328,6 +324,11 @@
EntityConfiguration entityCfg = new EntityConfiguration(auditEntityName,
idMapper,
propertyMapper, parentEntityName);
entitiesConfigurations.put(pc.getEntityName(), entityCfg);
+
+ Iterator subclasses = pc.getDirectSubclasses();
+ while (subclasses.hasNext()) {
+ entitiesConfigurations.put(((Subclass) subclasses.next()).getEntityName(),
entityCfg);
+ }
}
Whilst envers looked like it started up all fine, the moment I tried writing data via
hibernate very odd side effects came about.
Envers ignores empty discriminator classes
------------------------------------------
Key: HHH-3633
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-3633
Project: Hibernate Core
Issue Type: Bug
Components: envers
Affects Versions: 3.4
Reporter: Mark Derricutt
'lo
I'm just working through updating our system to Hibernate 3.3 and the new maven based
envers from trunk and am noticing that empty discriminator classes such as:
@Entity
@DiscriminatorValue("11004")
@Versioned
public class CountryGeo extends Geo {
}
are getting ignored by envers. This is manifested as the error "An audited relation
to a non-audited entity" thrown from ToOneRelationMetadataGenerator.
--
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