[Minor] removed setting of object on CTX - do by FactoryDelegator
When you implement a ContextFactory, and create the PersistenceContext, then set the object as well
This commit is contained in:
parent
b38c57e424
commit
97bd4fa089
|
@ -53,7 +53,6 @@ public class ObjectDao {
|
|||
assertNotClosed();
|
||||
assertNotNull(object);
|
||||
PersistenceContext<T> ctx = createCtx(object);
|
||||
ctx.setObject(object);
|
||||
ctx.getObjectRef().lock();
|
||||
this.objectFilter.add(ctx.getObjectRef().getType(), ctx);
|
||||
}
|
||||
|
@ -64,7 +63,6 @@ public class ObjectDao {
|
|||
if (!objects.isEmpty()) {
|
||||
for (T object : objects) {
|
||||
PersistenceContext<T> ctx = createCtx(object);
|
||||
ctx.setObject(object);
|
||||
ctx.getObjectRef().lock();
|
||||
this.objectFilter.add(ctx.getObjectRef().getType(), ctx);
|
||||
}
|
||||
|
@ -75,7 +73,6 @@ public class ObjectDao {
|
|||
assertNotClosed();
|
||||
assertNotNull(object);
|
||||
PersistenceContext<T> ctx = createCtx(object);
|
||||
ctx.setObject(object);
|
||||
ctx.getObjectRef().lock();
|
||||
this.objectFilter.update(ctx.getObjectRef().getType(), ctx);
|
||||
}
|
||||
|
@ -86,7 +83,6 @@ public class ObjectDao {
|
|||
if (!objects.isEmpty()) {
|
||||
for (T object : objects) {
|
||||
PersistenceContext<T> ctx = createCtx(object);
|
||||
ctx.setObject(object);
|
||||
ctx.getObjectRef().lock();
|
||||
this.objectFilter.update(ctx.getObjectRef().getType(), ctx);
|
||||
}
|
||||
|
@ -97,7 +93,6 @@ public class ObjectDao {
|
|||
assertNotClosed();
|
||||
assertNotNull(object);
|
||||
PersistenceContext<T> ctx = createCtx(object);
|
||||
ctx.setObject(object);
|
||||
ctx.getObjectRef().lock();
|
||||
this.objectFilter.remove(ctx.getObjectRef().getType(), ctx);
|
||||
}
|
||||
|
@ -108,7 +103,6 @@ public class ObjectDao {
|
|||
if (!objects.isEmpty()) {
|
||||
for (T object : objects) {
|
||||
PersistenceContext<T> ctx = createCtx(object);
|
||||
ctx.setObject(object);
|
||||
ctx.getObjectRef().lock();
|
||||
this.objectFilter.remove(ctx.getObjectRef().getType(), ctx);
|
||||
}
|
||||
|
@ -293,12 +287,12 @@ public class ObjectDao {
|
|||
}
|
||||
}
|
||||
|
||||
private <T> PersistenceContext<T> createCtx(T object) {
|
||||
public <T> PersistenceContext<T> createCtx(T object) {
|
||||
return this.ctxFactoryDelegator.<T> getCtxFactory(object.getClass()).createCtx(this.tx.getObjectRefCache(),
|
||||
object);
|
||||
}
|
||||
|
||||
private <T> PersistenceContext<T> createCtx(ObjectRef objectRef) {
|
||||
public <T> PersistenceContext<T> createCtx(ObjectRef objectRef) {
|
||||
String type = objectRef.getType();
|
||||
PersistenceContextFactory<T> ctxFactory = this.ctxFactoryDelegator.<T> getCtxFactory(type);
|
||||
return ctxFactory.createCtx(objectRef);
|
||||
|
|
|
@ -34,6 +34,8 @@ public class BookContextFactory implements PersistenceContextFactory<Book> {
|
|||
@Override
|
||||
public PersistenceContext<Book> createCtx(ObjectReferenceCache objectRefCache, Book t) {
|
||||
IdOfTypeRef objectRef = objectRefCache.getIdOfTypeRef(TestConstants.TYPE_BOOK, t.getId().toString());
|
||||
return createCtx(objectRef);
|
||||
PersistenceContext<Book> ctx = createCtx(objectRef);
|
||||
ctx.setObject(t);
|
||||
return ctx;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,9 @@ public class MyModelContextFactory implements PersistenceContextFactory<MyModel>
|
|||
@Override
|
||||
public PersistenceContext<MyModel> createCtx(ObjectReferenceCache objectRefCache, MyModel t) {
|
||||
IdOfSubTypeRef objectRef = objectRefCache.getIdOfSubTypeRef(TestConstants.TYPE_RES, t.getType(), t.getId());
|
||||
return createCtx(objectRef);
|
||||
PersistenceContext<MyModel> ctx = createCtx(objectRef);
|
||||
ctx.setObject(t);
|
||||
return ctx;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue