diff --git a/src/main/java/com/avaje/ebean/Ebean.java b/src/main/java/com/avaje/ebean/Ebean.java index 4383b3d8d..438547dfe 100644 --- a/src/main/java/com/avaje/ebean/Ebean.java +++ b/src/main/java/com/avaje/ebean/Ebean.java @@ -639,38 +639,6 @@ public final class Ebean { return serverMgr.getDefaultServer().saveAll(beans); } - /** - * Delete the associations (from the intersection table) of a ManyToMany given - * the owner bean and the propertyName of the ManyToMany collection. - *

- * Typically these deletions occur automatically when persisting a ManyToMany - * collection and this provides a way to invoke those deletions directly. - *

- * - * @return the number of associations deleted (from the intersection table). - */ - public static int deleteManyToManyAssociations(Object ownerBean, String propertyName) { - return serverMgr.getDefaultServer().deleteManyToManyAssociations(ownerBean, propertyName); - } - - /** - * Save the associations of a ManyToMany given the owner bean and the - * propertyName of the ManyToMany collection. - *

- * Typically the saving of these associations (inserting into the intersection - * table) occurs automatically when persisting a ManyToMany. This provides a - * way to invoke those insertions directly. - *

- *

- * You can use this when the collection is new and in this case all the - * entries in the collection are treated as additions are result in inserts - * into the intersection table. - *

- */ - public static void saveManyToManyAssociations(Object ownerBean, String propertyName) { - serverMgr.getDefaultServer().saveManyToManyAssociations(ownerBean, propertyName); - } - /** * Delete the bean. *

diff --git a/src/main/java/com/avaje/ebean/EbeanServer.java b/src/main/java/com/avaje/ebean/EbeanServer.java index 68512a7a6..e48eaa15c 100644 --- a/src/main/java/com/avaje/ebean/EbeanServer.java +++ b/src/main/java/com/avaje/ebean/EbeanServer.java @@ -1438,55 +1438,6 @@ public interface EbeanServer { */ void insertAll(Collection beans, Transaction transaction); - /** - * Delete the associations (from the intersection table) of a ManyToMany given - * the owner bean and the propertyName of the ManyToMany collection. - *

- * Typically these deletions occur automatically when persisting a ManyToMany - * collection and this provides a way to invoke those deletions directly. - *

- * - * @return the number of associations deleted (from the intersection table). - */ - int deleteManyToManyAssociations(Object ownerBean, String propertyName); - - /** - * Delete the associations (from the intersection table) of a ManyToMany given - * the owner bean and the propertyName of the ManyToMany collection. - *

- * Additionally specify a transaction to use. - *

- *

- * Typically these deletions occur automatically when persisting a ManyToMany - * collection and this provides a way to invoke those deletions directly. - *

- * - * @return the number of associations deleted (from the intersection table). - */ - int deleteManyToManyAssociations(Object ownerBean, String propertyName, Transaction transaction); - - /** - * Save the associations of a ManyToMany given the owner bean and the - * propertyName of the ManyToMany collection. - *

- * Typically the saving of these associations (inserting into the intersection - * table) occurs automatically when persisting a ManyToMany. This provides a - * way to invoke those insertions directly. - *

- */ - void saveManyToManyAssociations(Object ownerBean, String propertyName); - - /** - * Save the associations of a ManyToMany given the owner bean and the - * propertyName of the ManyToMany collection. - *

- * Typically the saving of these associations (inserting into the intersection - * table) occurs automatically when persisting a ManyToMany. This provides a - * way to invoke those insertions directly. - *

- */ - void saveManyToManyAssociations(Object ownerBean, String propertyName, Transaction transaction); - /** * Execute explicitly passing a transaction. */ diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/DefaultServer.java b/src/main/java/com/avaje/ebeaninternal/server/core/DefaultServer.java index 83aa6b2d5..024f02b9c 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/DefaultServer.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/DefaultServer.java @@ -1535,69 +1535,6 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { return (EntityBean)bean; } - /** - * Delete the associations (from the intersection table) of a ManyToMany given - * the owner bean and the propertyName of the ManyToMany collection. - *

- * This returns the number of associations deleted. - *

- */ - public int deleteManyToManyAssociations(Object ownerBean, String propertyName) { - return deleteManyToManyAssociations(ownerBean, propertyName, null); - } - - /** - * Delete the associations (from the intersection table) of a ManyToMany given - * the owner bean and the propertyName of the ManyToMany collection. - *

- * This returns the number of associations deleted. - *

- */ - public int deleteManyToManyAssociations(Object ownerBean, String propertyName, Transaction t) { - - EntityBean owner = checkEntityBean(ownerBean); - TransWrapper wrap = initTransIfRequired(t); - try { - SpiTransaction trans = wrap.transaction; - int rc = persister.deleteManyToManyAssociations(owner, propertyName, trans); - wrap.commitIfCreated(); - return rc; - - } catch (RuntimeException e) { - wrap.rollbackIfCreated(); - throw e; - } - } - - /** - * Save the associations of a ManyToMany given the owner bean and the - * propertyName of the ManyToMany collection. - */ - public void saveManyToManyAssociations(Object ownerBean, String propertyName) { - saveManyToManyAssociations(ownerBean, propertyName, null); - } - - /** - * Save the associations of a ManyToMany given the owner bean and the - * propertyName of the ManyToMany collection. - */ - public void saveManyToManyAssociations(Object ownerBean, String propertyName, Transaction t) { - - EntityBean owner = checkEntityBean(ownerBean); - TransWrapper wrap = initTransIfRequired(t); - try { - SpiTransaction trans = wrap.transaction; - - persister.saveManyToManyAssociations(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); diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/Persister.java b/src/main/java/com/avaje/ebeaninternal/server/core/Persister.java index d2c7fc79e..512b62525 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/Persister.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/Persister.java @@ -35,17 +35,6 @@ public interface Persister { */ void save(EntityBean entityBean, Transaction t); - /** - * Save the associations of a ManyToMany given the owner bean and the - * propertyName of the ManyToMany collection. - */ - void saveManyToManyAssociations(EntityBean ownerBean, String propertyName, Transaction t); - - /** - * Delete the associations of a ManyToMany given the owner bean and the property name of the ManyToMany. - */ - int deleteManyToManyAssociations(EntityBean ownerBean, String propertyName, Transaction t); - /** * Delete a bean given it's type and id value. *

diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/DefaultPersister.java b/src/main/java/com/avaje/ebeaninternal/server/persist/DefaultPersister.java index 3d89097f7..549c3768c 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/DefaultPersister.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/DefaultPersister.java @@ -1071,21 +1071,6 @@ public final class DefaultPersister implements Persister { t.depth(-1); } - public int deleteManyToManyAssociations(EntityBean ownerBean, String propertyName, Transaction t) { - - BeanDescriptor descriptor = beanDescriptorManager.getBeanDescriptor(ownerBean.getClass()); - BeanPropertyAssocMany prop = (BeanPropertyAssocMany) descriptor.getBeanProperty(propertyName); - return deleteAssocManyIntersection(ownerBean, prop, t, false); - } - - public void saveManyToManyAssociations(EntityBean ownerBean, String propertyName, Transaction t) { - - BeanDescriptor descriptor = beanDescriptorManager.getBeanDescriptor(ownerBean.getClass()); - BeanPropertyAssocMany prop = (BeanPropertyAssocMany) descriptor.getBeanProperty(propertyName); - - saveAssocManyIntersection(new SaveManyPropRequest(prop, ownerBean, (SpiTransaction) t), false); - } - /** * Save the additions and removals from a ManyToMany collection as inserts * and deletes from the intersection table. diff --git a/src/test/java/com/avaje/ebeaninternal/api/TDSpiEbeanServer.java b/src/test/java/com/avaje/ebeaninternal/api/TDSpiEbeanServer.java index bd8c4d905..adab60645 100644 --- a/src/test/java/com/avaje/ebeaninternal/api/TDSpiEbeanServer.java +++ b/src/test/java/com/avaje/ebeaninternal/api/TDSpiEbeanServer.java @@ -608,26 +608,6 @@ public class TDSpiEbeanServer implements SpiEbeanServer { } - @Override - public int deleteManyToManyAssociations(Object ownerBean, String propertyName) { - return 0; - } - - @Override - public int deleteManyToManyAssociations(Object ownerBean, String propertyName, Transaction t) { - return 0; - } - - @Override - public void saveManyToManyAssociations(Object ownerBean, String propertyName) { - - } - - @Override - public void saveManyToManyAssociations(Object ownerBean, String propertyName, Transaction t) { - - } - @Override public boolean delete(Object bean, Transaction t) throws OptimisticLockException { return false; diff --git a/src/test/java/com/avaje/tests/basic/TestM2MVanilla.java b/src/test/java/com/avaje/tests/basic/TestM2MVanilla.java index a3dc99d59..3d883eec8 100644 --- a/src/test/java/com/avaje/tests/basic/TestM2MVanilla.java +++ b/src/test/java/com/avaje/tests/basic/TestM2MVanilla.java @@ -87,12 +87,9 @@ public class TestM2MVanilla extends BaseTestCase { List roles = mUser.getRoles(); Assert.assertEquals(1, roles.size()); -// Ebean.refreshMany(mUser, "roles"); -// Assert.assertEquals(1, mUser.getRoles().size()); - checkRoles2.remove(0); checkRoles2.remove(0); - Ebean.saveManyToManyAssociations(checkUser2, "roles"); + Ebean.save(checkUser2); checkUser2 = Ebean.find(MUser.class, u0.getUserid()); checkRoles2 = checkUser2.getRoles(); diff --git a/src/test/java/com/avaje/tests/m2m/TestM2MDeleteNoCascade.java b/src/test/java/com/avaje/tests/m2m/TestM2MDeleteNoCascade.java index 14e2efe4e..dbb08cfe5 100644 --- a/src/test/java/com/avaje/tests/m2m/TestM2MDeleteNoCascade.java +++ b/src/test/java/com/avaje/tests/m2m/TestM2MDeleteNoCascade.java @@ -41,11 +41,9 @@ public class TestM2MDeleteNoCascade extends BaseTestCase { Assert.assertTrue(true); } - int rc = Ebean.deleteManyToManyAssociations(u0, "validRoles"); - Assert.assertTrue(rc != 0); + u0.getValidRoles().clear(); + Ebean.save(u0); Ebean.delete(u0); - Assert.assertTrue(true); - } }