question about targetAuditMode
skomarla Dec 7, 2009 3:00 PMAdam,
I am back to evaluating envers after a little bit of a hiatus and I am trying to use the 1.2.2-SNAPSHOT.
I have a question. I have a object with a many-to-many association with another object that has joined subclasses
class Routing
@Audited public class Routing extends Base implements Serializable { ...snip... @Audited(targetAuditMode=RelationTargetAuditMode.NOT_AUDITED) private Set<Jurisdiction> jurisdictions = new HashSet<Jurisdiction>(0);
mapping for Routing
<class name="com.xyz.model.Routing" table="NODE_ROUTING"> <id name="id" type="int"> <column name="Node_Routing_ID" /> <generator class="identity" /> </id> ...snip... <set name="jurisdictions" table="NODE_ROUTING_JURISDICTION"> <key> <column name="Node_Routing_ID" not-null="true" /> </key> <many-to-many entity-name="com.xyz.model.Jurisdiction"> <column name="Jurisdiction_ID" not-null="true" /> </many-to-many> </set> </class>
Jurisdiction class and it's subclasses are not Audited.
mapping for Jurisdiction
<class name="com.xyz.model.Jurisdiction" table="JURISDICTION" lazy="false"> <id name="id" type="int"> <column name="Jurisdiction_ID" /> <generator class="identity" /> </id> <many-to-one name="type" class="com.xyz.model.JurisdictionType" fetch="select"> <column name="Jurisdiction_Type_ID" not-null="true" /> </many-to-one> <!-- country jursidiction type --> <joined-subclass name="com.xyz.model.Country" table="JURISDICTION_COUNTRY"> <key column="Jurisdiction_ID" /> <property name="name" type="string"> <column name="Country_NME" length="50" /> </property> <property name="a3Code" type="string"> <column name="Country_A3_CD" length="3" unique="true" /> </property> <property name="a2Code" type="string"> <column name="Country_A2_CD" length="2" unique="true" /> </property> <property name="isoCode" type="string"> <column name="Country_ISO_CD" length="3" /> </property> </joined-subclass> <!-- county jurisdiction type --> <joined-subclass name="com.xyz.model.County" table="JURISDICTION_COUNTY"> <key column="Jurisdiction_ID" /> <property name="name" type="string"> <column name="County" length="60" /> </property> <property name="stateA2Code" type="string"> <column name="State_A2_CD" length="2" /> </property> <property name="countryA2Code" type="string"> <column name="Country_A2_CD" length="2" /> </property> </joined-subclass> <!-- state jurisdiction type --> <joined-subclass name="com.xyz.model.State" table="JURISDICTION_STATE"> <key column="Jurisdiction_ID" /> <property name="name" type="string"> <column name="State_NME" length="60" /> </property> <property name="a2Code" type="string"> <column name="State_A2_CD" length="2" /> </property> <property name="countryA2Code" type="string"> <column name="Country_A2_CD" length="2" /> </property> </joined-subclass> </class>
Now.. when I start up my appserver or a junit, get this exception.
Caused by: org.hibernate.MappingException: An audited relation from com.xyz.model.Routing to a non-audited entity: com.xyz.model.Jurisdiction at org.hibernate.envers.configuration.metadata.CollectionMetadataGenerator.throwRelationNotAudited(CollectionMetadataGenerator.java:546) at org.hibernate.envers.configuration.metadata.CollectionMetadataGenerator.addValueToMiddleTable(CollectionMetadataGenerator.java:396) at org.hibernate.envers.configuration.metadata.CollectionMetadataGenerator.addWithMiddleTable(CollectionMetadataGenerator.java:316) at org.hibernate.envers.configuration.metadata.CollectionMetadataGenerator.addCollection(CollectionMetadataGenerator.java:154) at org.hibernate.envers.configuration.metadata.AuditMetadataGenerator.addValue(AuditMetadataGenerator.java:159) at org.hibernate.envers.configuration.metadata.AuditMetadataGenerator.addProperties(AuditMetadataGenerator.java:179) at org.hibernate.envers.configuration.metadata.AuditMetadataGenerator.generateSecondPass(AuditMetadataGenerator.java:476) at org.hibernate.envers.configuration.EntitiesConfigurator.configure(EntitiesConfigurator.java:103) at org.hibernate.envers.configuration.AuditConfiguration.<init>(AuditConfiguration.java:86) at org.hibernate.envers.configuration.AuditConfiguration.getFor(AuditConfiguration.java:99) at org.hibernate.envers.event.AuditEventListener.initialize(AuditEventListener.java:260) 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) ... 184 more
Now, I have other instances where I set the targetAuditMode to not audited in other attributes of Routing, but here, envers seems to care (perhaps not extending the targetAuditMode to subclasses.
Is this an issue or am I misinterpreting something?
Thanks,