#720 - Remove EbeanServer saveAssociation(Object ownerBean, String propertyName); ... migrate to just save the bean

This commit is contained in:
Robin Bygrave
2016-05-20 23:24:37 +12:00
parent 7268890332
commit 0e1aacdeee
8 changed files with 2 additions and 133 deletions
-20
View File
@@ -671,26 +671,6 @@ public final class Ebean {
serverMgr.getDefaultServer().saveManyToManyAssociations(ownerBean, propertyName);
}
/**
* Save the associated collection or bean given the property name.
* <p>
* This is similar to performing a save cascade on a specific property
* manually/programmatically.
* </p>
* <p>
* Note that you can turn on/off cascading for a transaction via
* {@link Transaction#setPersistCascade(boolean)}
* </p>
*
* @param ownerBean
* the bean instance holding the property we want to save
* @param propertyName
* the property we want to save
*/
public static void saveAssociation(Object ownerBean, String propertyName) {
serverMgr.getDefaultServer().saveAssociation(ownerBean, propertyName);
}
/**
* Delete the bean.
* <p>
@@ -1487,44 +1487,6 @@ public interface EbeanServer {
*/
void saveManyToManyAssociations(Object ownerBean, String propertyName, Transaction transaction);
/**
* Save the associated collection or bean given the property name.
* <p>
* This is similar to performing a save cascade on a specific property
* manually.
* </p>
* <p>
* Note that you can turn on/off cascading for a transaction via
* {@link Transaction#setPersistCascade(boolean)}
* </p>
*
* @param ownerBean
* the bean instance holding the property we want to save
* @param propertyName
* the property we want to save
*/
void saveAssociation(Object ownerBean, String propertyName);
/**
* Save the associated collection or bean given the property name with a
* specific transaction.
* <p>
* This is similar to performing a save cascade on a specific property
* manually.
* </p>
* <p>
* Note that you can turn on/off cascading for a transaction via
* {@link Transaction#setPersistCascade(boolean)}
* </p>
*
* @param ownerBean
* the bean instance holding the property we want to save
* @param propertyName
* the property we want to save
*/
void saveAssociation(Object ownerBean, String propertyName, Transaction transaction);
/**
* Execute explicitly passing a transaction.
*/
@@ -1598,27 +1598,6 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
}
}
public void saveAssociation(Object ownerBean, String propertyName) {
saveAssociation(ownerBean, propertyName, null);
}
public void saveAssociation(Object ownerBean, String propertyName, Transaction t) {
EntityBean owner = checkEntityBean(ownerBean);
TransWrapper wrap = initTransIfRequired(t);
try {
SpiTransaction trans = wrap.transaction;
persister.saveAssociation(owner, propertyName, trans);
wrap.commitIfCreated();
} catch (RuntimeException e) {
wrap.rollbackIfCreated();
throw e;
}
}
@Override
public int saveAll(Collection<?> beans, Transaction transaction) throws OptimisticLockException {
return saveAllInternal(beans.iterator(), transaction);
@@ -41,15 +41,6 @@ public interface Persister {
*/
void saveManyToManyAssociations(EntityBean ownerBean, String propertyName, Transaction t);
/**
* Save an association (OneToMany, ManyToOne, OneToOne or ManyToMany).
*
* @param parentBean the bean that owns the association.
* @param propertyName the name of the property to save.
* @param t the transaction to use.
*/
void saveAssociation(EntityBean parentBean, String propertyName, Transaction t);
/**
* Delete the associations of a ManyToMany given the owner bean and the property name of the ManyToMany.
*/
@@ -1086,39 +1086,6 @@ public final class DefaultPersister implements Persister {
saveAssocManyIntersection(new SaveManyPropRequest(prop, ownerBean, (SpiTransaction) t), false);
}
public void saveAssociation(EntityBean parentBean, String propertyName, Transaction t) {
BeanDescriptor<?> descriptor = beanDescriptorManager.getBeanDescriptor(parentBean.getClass());
SpiTransaction trans = (SpiTransaction) t;
BeanProperty prop = descriptor.getBeanProperty(propertyName);
if (prop == null) {
String msg = "Could not find property [" + propertyName + "] on bean " + parentBean.getClass();
throw new PersistenceException(msg);
}
if (prop instanceof BeanPropertyAssocMany<?>) {
BeanPropertyAssocMany<?> manyProp = (BeanPropertyAssocMany<?>) prop;
saveMany(new SaveManyPropRequest(manyProp, parentBean, (SpiTransaction) t), true);
} else if (prop instanceof BeanPropertyAssocOne<?>) {
BeanPropertyAssocOne<?> oneProp = (BeanPropertyAssocOne<?>) prop;
EntityBean assocBean = oneProp.getValueAsEntityBean(parentBean);
int depth = oneProp.isOneToOneExported() ? 1 : -1;
int revertDepth = -1 * depth;
trans.depth(depth);
saveRecurse(assocBean, t, parentBean, true, false);
trans.depth(revertDepth);
} else {
String msg = "Expecting [" + prop.getFullBeanName() + "] to be a OneToMany, OneToOne, ManyToOne or ManyToMany property?";
throw new PersistenceException(msg);
}
}
/**
* Save the additions and removals from a ManyToMany collection as inserts
* and deletes from the intersection table.