Author: adamw
Date: 2008-07-16 03:22:43 -0400 (Wed, 16 Jul 2008)
New Revision: 91
Modified:
trunk/build.xml
trunk/src/main/org/jboss/envers/entity/EntityInstantiator.java
trunk/src/main/org/jboss/envers/query/impl/EntitiesAtRevisionQuery.java
trunk/src/main/org/jboss/envers/query/impl/RevisionsOfEntityQuery.java
Log:
Fixing a bug with using JPA, not Hibernate (then, the $type$ property isn't always
present)
Modified: trunk/build.xml
===================================================================
--- trunk/build.xml 2008-07-04 07:04:46 UTC (rev 90)
+++ trunk/build.xml 2008-07-16 07:22:43 UTC (rev 91)
@@ -10,7 +10,7 @@
<property name="dist.jar.32.name"
value="${project.name}-${project.version}${hibernate.32.version}.jar" />
<property name="dist.jar.33.name"
value="${project.name}-${project.version}${hibernate.33.version}.jar" />
- <property name="dist.demo.name"
value="${project.name}-${project.version}-demo.jar" />
+ <property name="dist.demo.name"
value="${project.name}-console-demo.jar" />
<property name="dist.src.name"
value="${project.name}-${project.version}-src.zip" />
<property name="dist.dir" value="dist" />
Modified: trunk/src/main/org/jboss/envers/entity/EntityInstantiator.java
===================================================================
--- trunk/src/main/org/jboss/envers/entity/EntityInstantiator.java 2008-07-04 07:04:46 UTC
(rev 90)
+++ trunk/src/main/org/jboss/envers/entity/EntityInstantiator.java 2008-07-16 07:22:43 UTC
(rev 91)
@@ -46,12 +46,13 @@
/**
* Creates an entity instance based on an entry from the versions table.
+ * @param entityName Name of the entity, which instances should be read
* @param versionsEntity An entry in the versions table, from which data should be
mapped.
* @param revision Revision at which this entity was read.
* @return An entity instance, with versioned properties set as in the versionsEntity
map, and proxies
* created for collections.
*/
- public Object createInstanceFromVersionsEntity(Map versionsEntity, Number revision)
{
+ public Object createInstanceFromVersionsEntity(String entityName, Map versionsEntity,
Number revision) {
if (versionsEntity == null) {
return null;
}
@@ -62,10 +63,14 @@
}
// The $type$ property holds the name of the (versions) entity
- String entityName = verCfg.getEntityNameForVersionsEntityName((String)
versionsEntity.get("$type$"));
+ String type = verCfg.getEntityNameForVersionsEntityName((String)
versionsEntity.get("$type$"));
+ if (type != null) {
+ entityName = type;
+ }
+
Object ret;
- try {
+ try {
Class<?> cls = ReflectionTools.loadClass(entityName);
ret = cls.newInstance();
} catch (Exception e) {
@@ -84,9 +89,9 @@
}
@SuppressWarnings({"unchecked"})
- public void addInstancesFromVersionsEntities(List list, List<Map>
versionsEntities, Number revision) {
+ public void addInstancesFromVersionsEntities(String entityName, List list,
List<Map> versionsEntities, Number revision) {
for (Map versionsEntity : versionsEntities) {
- list.add(createInstanceFromVersionsEntity(versionsEntity, revision));
+ list.add(createInstanceFromVersionsEntity(entityName, versionsEntity,
revision));
}
}
}
Modified: trunk/src/main/org/jboss/envers/query/impl/EntitiesAtRevisionQuery.java
===================================================================
--- trunk/src/main/org/jboss/envers/query/impl/EntitiesAtRevisionQuery.java 2008-07-04
07:04:46 UTC (rev 90)
+++ trunk/src/main/org/jboss/envers/query/impl/EntitiesAtRevisionQuery.java 2008-07-16
07:22:43 UTC (rev 91)
@@ -75,7 +75,7 @@
return queryResult;
} else {
List result = new ArrayList();
- entityInstantiator.addInstancesFromVersionsEntities(result, queryResult,
revision);
+ entityInstantiator.addInstancesFromVersionsEntities(entityName, result,
queryResult, revision);
return result;
}
Modified: trunk/src/main/org/jboss/envers/query/impl/RevisionsOfEntityQuery.java
===================================================================
--- trunk/src/main/org/jboss/envers/query/impl/RevisionsOfEntityQuery.java 2008-07-04
07:04:46 UTC (rev 90)
+++ trunk/src/main/org/jboss/envers/query/impl/RevisionsOfEntityQuery.java 2008-07-16
07:22:43 UTC (rev 91)
@@ -71,7 +71,7 @@
for (Map versionsEntity : queryResult) {
Number revision = (Number) ((Map)
versionsEntity.get(originalId)).get(revisionPropertyName);
- Object entity =
entityInstantiator.createInstanceFromVersionsEntity(versionsEntity, revision);
+ Object entity =
entityInstantiator.createInstanceFromVersionsEntity(entityName, versionsEntity,
revision);
if (!selectEntitiesOnly) {
entities.add(new Object[] { entity, revision });
Show replies by date