[Minor] modified how objects are added to the ObjectFilter

Now objects are not added by their class names, but the type is
retrieved from the object reference
This commit is contained in:
Robert von Burg 2013-10-24 21:45:11 +02:00
parent f24a10992c
commit 59635eddf1
3 changed files with 8 additions and 13 deletions

View File

@ -58,7 +58,7 @@ public class ObjectDao {
PersistenceContext<T> ctx = createCtx(object);
ctx.setObject(object);
ctx.getObjectRef().lock();
this.objectFilter.add(object.getClass().getName(), ctx);
this.objectFilter.add(ctx.getObjectRef().getType(), ctx);
}
public <T> void addAll(List<T> objects) {
@ -69,7 +69,7 @@ public class ObjectDao {
PersistenceContext<T> ctx = createCtx(object);
ctx.setObject(object);
ctx.getObjectRef().lock();
this.objectFilter.add(object.getClass().getName(), ctx);
this.objectFilter.add(ctx.getObjectRef().getType(), ctx);
}
}
}
@ -80,7 +80,7 @@ public class ObjectDao {
PersistenceContext<T> ctx = createCtx(object);
ctx.setObject(object);
ctx.getObjectRef().lock();
this.objectFilter.update(object.getClass().getName(), ctx);
this.objectFilter.update(ctx.getObjectRef().getType(), ctx);
}
public <T> void updateAll(List<T> objects) {
@ -91,7 +91,7 @@ public class ObjectDao {
PersistenceContext<T> ctx = createCtx(object);
ctx.setObject(object);
ctx.getObjectRef().lock();
this.objectFilter.update(object.getClass().getName(), ctx);
this.objectFilter.update(ctx.getObjectRef().getType(), ctx);
}
}
}
@ -102,7 +102,7 @@ public class ObjectDao {
PersistenceContext<T> ctx = createCtx(object);
ctx.setObject(object);
ctx.getObjectRef().lock();
this.objectFilter.remove(object.getClass().getName(), ctx);
this.objectFilter.remove(ctx.getObjectRef().getType(), ctx);
}
public <T> void removeAll(List<T> objects) {
@ -113,7 +113,7 @@ public class ObjectDao {
PersistenceContext<T> ctx = createCtx(object);
ctx.setObject(object);
ctx.getObjectRef().lock();
this.objectFilter.remove(object.getClass().getName(), ctx);
this.objectFilter.remove(ctx.getObjectRef().getType(), ctx);
}
}
}

View File

@ -44,8 +44,6 @@ public class PersistenceContextFactoryDelegator {
this.contextFactoryCacheByClass.put(classType, ctxFactory);
this.contextFactoryCacheByType.put(type, ctxFactory);
if (!classType.getName().equals(type))
this.contextFactoryCacheByType.put(classType.getName(), ctxFactory);
}
public <T> PersistenceContextFactory<T> getCtxFactory(Class<?> classType) {

View File

@ -21,15 +21,12 @@
*/
package ch.eitchnet.xmlpers.test.impl;
import ch.eitchnet.xmlpers.test.model.Book;
import ch.eitchnet.xmlpers.test.model.Resource;
/**
* @author Robert von Burg <eitch@eitchnet.ch>
*
*/
public class TestConstants {
public static final String TYPE_RES = Resource.class.getSimpleName();
public static final String TYPE_BOOK = Book.class.getSimpleName();
public static final String TYPE_RES = "Resource"; //$NON-NLS-1$
public static final String TYPE_BOOK = "Book"; //$NON-NLS-1$
}