Remove Subclassing/Dynamic Proxy support - beans must be enhanced

This commit is contained in:
Robin Bygrave committed 2013-04-19 16:25:10 +12:00
1 parent 66880aa340
commit 2567022d95
63 files changed
+233 -2085

No files matched your search

@@ -70,8 +70,8 @@ public final class DefaultPersister implements Persister {
private final BeanDescriptorManager beanDescriptorManager;
private final boolean defaultUpdateNullProperties;
private final boolean defaultDeleteMissingChildren;
// private final boolean defaultUpdateNullProperties;
// private final boolean defaultDeleteMissingChildren;
public DefaultPersister(SpiEbeanServer server, Binder binder, BeanDescriptorManager descMgr, PstmtBatch pstmtBatch) {
@@ -79,8 +79,8 @@ public final class DefaultPersister implements Persister {
this.beanDescriptorManager = descMgr;
this.persistExecute = new DefaultPersistExecute(binder, pstmtBatch);
this.defaultUpdateNullProperties = server.isDefaultUpdateNullProperties();
this.defaultDeleteMissingChildren = server.isDefaultDeleteMissingChildren();
// this.defaultUpdateNullProperties = server.isDefaultUpdateNullProperties();
// this.defaultDeleteMissingChildren = server.isDefaultDeleteMissingChildren();
}
/**
@@ -271,8 +271,7 @@ public final class DefaultPersister implements Persister {
}
if (bean instanceof EntityBean == false) {
saveVanillaRecurse(bean, t, parentBean);
return;
throw new IllegalArgumentException("This bean is of type ["+bean.getClass()+"] is not enhanced?");
}
PersistRequestBean<?> req = createRequest(bean, t, parentBean);
@@ -313,42 +312,6 @@ public final class DefaultPersister implements Persister {
}
}
/**
* Determine if this is an Insert or update for the 'vanilla' bean.
*/
private void saveVanillaRecurse(Object bean, Transaction t, Object parentBean) {
BeanManager<?> mgr = getBeanManager(bean);
if (mgr == null) {
throw new RuntimeException("No Mgr found for " + bean + " " + bean.getClass());
}
// use the version property to determine insert or update
if (mgr.getBeanDescriptor().isVanillaInsert(bean)) {
saveVanillaInsert(bean, t, parentBean, mgr);
} else {
// update non-null properties (no partial object knowledge with vanilla bean)
forceUpdateStateless(bean, t, parentBean, mgr, null, defaultDeleteMissingChildren, defaultUpdateNullProperties);
}
}
/**
* Perform insert on non-enhanced bean (effectively same as enhanced bean).
*/
private void saveVanillaInsert(Object bean, Transaction t, Object parentBean, BeanManager<?> mgr) {
PersistRequestBean<?> req = createRequest(bean, t, parentBean, mgr);
try {
req.initTransIfRequired();
insert(req);
req.commitTransIfRequired();
} catch (RuntimeException ex) {
req.rollbackTransIfRequired();
throw ex;
}
}
/**
* Insert the bean.
*/
@@ -72,8 +72,8 @@ public class MetaFactory {
embeddedFact.create(allList, desc, DmlMode.WHERE, false);
assocOneFact.create(allList, desc, DmlMode.WHERE);
Bindable setBindable = new BindableList(setList);
Bindable allBindable = new BindableList(allList);
BindableList setBindable = new BindableList(setList);
BindableList allBindable = new BindableList(allList);
return new UpdateMeta(emptyStringAsNull, desc, setBindable, id, ver, allBindable);
}
@@ -25,7 +25,7 @@ public final class UpdateMeta {
private final String sqlNone;
private final Bindable set;
private final BindableList set;
private final BindableId id;
private final Bindable version;
private final Bindable all;
@@ -37,7 +37,7 @@ public final class UpdateMeta {
private final boolean emptyStringAsNull;
public UpdateMeta(boolean emptyStringAsNull, BeanDescriptor<?> desc, Bindable set, BindableId id, Bindable version, Bindable all) {
public UpdateMeta(boolean emptyStringAsNull, BeanDescriptor<?> desc, BindableList set, BindableId id, Bindable version, Bindable all) {
this.emptyStringAsNull = emptyStringAsNull;
this.tableName = desc.getBaseTable();
this.set = set;
@@ -154,7 +154,12 @@ public final class UpdateMeta {
// build a bindableList that only contains the changed properties
List<Bindable> list = new ArrayList<Bindable>();
set.addChanged(persistRequest, list);
if (updatedProps == null) {
// update all the properties
set.addAll(list);
} else {
set.addChanged(persistRequest, list);
}
BindableList bindableList = new BindableList(list);
// build the SQL for this update statement
@@ -17,6 +17,12 @@ public class BindableList implements Bindable {
items = list.toArray(new Bindable[list.size()]);
}
public void addAll(List<Bindable> list) {
for (int i = 0; i < items.length; i++) {
list.add(items[i]);
}
}
public void addChanged(PersistRequestBean<?> request, List<Bindable> list) {
for (int i = 0; i < items.length; i++) {
items[i].addChanged(request, list);