Author: adamw
Date: 2009-12-01 02:31:01 -0500 (Tue, 01 Dec 2009)
New Revision: 18110
Modified:
core/branches/envers-hibernate-3.3/src/main/java/org/hibernate/envers/configuration/metadata/AuditMetadataGenerator.java
core/branches/envers-hibernate-3.3/src/main/java/org/hibernate/envers/configuration/metadata/IdMetadataGenerator.java
Log:
svn merge -r 18056:18109
https://svn.jboss.org/repos/hibernate/core/trunk/envers .
Modified:
core/branches/envers-hibernate-3.3/src/main/java/org/hibernate/envers/configuration/metadata/AuditMetadataGenerator.java
===================================================================
---
core/branches/envers-hibernate-3.3/src/main/java/org/hibernate/envers/configuration/metadata/AuditMetadataGenerator.java 2009-12-01
07:20:17 UTC (rev 18109)
+++
core/branches/envers-hibernate-3.3/src/main/java/org/hibernate/envers/configuration/metadata/AuditMetadataGenerator.java 2009-12-01
07:31:01 UTC (rev 18110)
@@ -45,6 +45,8 @@
import org.hibernate.cfg.Configuration;
import org.hibernate.mapping.*;
import org.hibernate.type.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* @author Adam Warski (adam at warski dot org)
@@ -52,6 +54,8 @@
* @author Tomasz Bech
*/
public final class AuditMetadataGenerator {
+ private static final Logger log =
LoggerFactory.getLogger(AuditMetadataGenerator.class);
+
private final Configuration cfg;
private final GlobalConfiguration globalCfg;
private final AuditEntitiesConfiguration verEntCfg;
@@ -349,6 +353,15 @@
if (!isAudited) {
String entityName = pc.getEntityName();
IdMappingData idMapper = idMetadataGenerator.addId(pc);
+
+ if (idMapper == null) {
+ // Unsupported id mapping, e.g. key-many-to-one. If the entity is used in
auditing, an exception
+ // will be thrown later on.
+ log.debug("Unable to create auditing id mapping for entity " +
entityName +
+ ", because of an unsupported Hibernate id mapping (e.g.
key-many-to-one).");
+ return;
+ }
+
ExtendedPropertyMapper propertyMapper = null;
String parentEntityName = null;
EntityConfiguration entityCfg = new EntityConfiguration(entityName, idMapper,
propertyMapper,
@@ -358,6 +371,8 @@
}
String entityName = pc.getEntityName();
+ log.debug("Generating first-pass auditing mapping for entity " +
entityName + ".");
+
String auditEntityName = verEntCfg.getAuditEntityName(entityName);
String auditTableName = verEntCfg.getAuditTableName(entityName,
pc.getTable().getName());
@@ -432,6 +447,7 @@
public void generateSecondPass(PersistentClass pc, ClassAuditingData auditingData,
EntityXmlMappingData xmlMappingData) {
String entityName = pc.getEntityName();
+ log.debug("Generating second-pass auditing mapping for entity " +
entityName + ".");
CompositeMapperBuilder propertyMapper =
entitiesConfigurations.get(entityName).getPropertyMapper();
Modified:
core/branches/envers-hibernate-3.3/src/main/java/org/hibernate/envers/configuration/metadata/IdMetadataGenerator.java
===================================================================
---
core/branches/envers-hibernate-3.3/src/main/java/org/hibernate/envers/configuration/metadata/IdMetadataGenerator.java 2009-12-01
07:20:17 UTC (rev 18109)
+++
core/branches/envers-hibernate-3.3/src/main/java/org/hibernate/envers/configuration/metadata/IdMetadataGenerator.java 2009-12-01
07:31:01 UTC (rev 18110)
@@ -84,6 +84,11 @@
Property id_prop = pc.getIdentifierProperty();
Component id_mapper = pc.getIdentifierMapper();
+ // Checking if the id mapping is supported
+ if (id_mapper == null && id_prop == null) {
+ return null;
+ }
+
SimpleIdMapperBuilder mapper;
if (id_mapper != null) {
// Multiple id