From 1119b665f86c26b5f8710ef4ba2225295d8a703e Mon Sep 17 00:00:00 2001 From: Ben Alex Date: Fri, 9 Sep 2005 03:58:04 +0000 Subject: [PATCH] Make createOrUpdate(E) delegate to Manager methods, not to the DAO method of the same name. --- .../main/java/org/acegisecurity/domain/dao/Dao.java | 13 ------------- .../acegisecurity/domain/service/ManagerImpl.java | 12 ++++++++---- 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/domain/src/main/java/org/acegisecurity/domain/dao/Dao.java b/domain/src/main/java/org/acegisecurity/domain/dao/Dao.java index 3c4058f39b..8640ee9020 100644 --- a/domain/src/main/java/org/acegisecurity/domain/dao/Dao.java +++ b/domain/src/main/java/org/acegisecurity/domain/dao/Dao.java @@ -72,19 +72,6 @@ public interface Dao { */ public E create(E value); - /** - * Saves an existing object to the persistence layer, or creates a new - * object in the persistence layer. Implementations typically rely on - * {@link PersistableEntity#getInternalId()} being non-null - * to differentiate between persistence instances previous saved and those - * requiring initial creation. - * - * @param value to save or update - * - * @return the saved or updated (as appropriate) value - */ - public E createOrUpdate(E value); - /** * Delete an object. * diff --git a/domain/src/main/java/org/acegisecurity/domain/service/ManagerImpl.java b/domain/src/main/java/org/acegisecurity/domain/service/ManagerImpl.java index 3f68683c48..99d22e3665 100644 --- a/domain/src/main/java/org/acegisecurity/domain/service/ManagerImpl.java +++ b/domain/src/main/java/org/acegisecurity/domain/service/ManagerImpl.java @@ -16,8 +16,6 @@ package net.sf.acegisecurity.domain.service; import java.io.Serializable; -import java.lang.reflect.ParameterizedType; -import java.lang.reflect.Type; import java.util.Collection; import java.util.List; @@ -26,7 +24,6 @@ import net.sf.acegisecurity.domain.dao.Dao; import net.sf.acegisecurity.domain.dao.PaginatedList; import net.sf.acegisecurity.domain.util.GenericsUtils; -import org.springframework.beans.factory.BeanNameAware; import org.springframework.beans.factory.InitializingBean; import org.springframework.context.support.ApplicationObjectSupport; import org.springframework.transaction.annotation.Transactional; @@ -106,12 +103,19 @@ public class ManagerImpl extends ApplicationObjectS return dao.create(value); } + /** + * Delegates to the appropriate services layer method (not the DAO). + */ public E createOrUpdate(E value) { Assert.notNull(value); if (logger.isDebugEnabled()) { logger.debug("CreatingOrUpdating: " + value); } - return dao.createOrUpdate(value); + if (value.getInternalId() == null) { + return create(value); + } else { + return update(value); + } } public void delete(E value) {