Make createOrUpdate(E) delegate to Manager methods, not to the DAO method of the same name.
This commit is contained in:
parent
3794c608ad
commit
1119b665f8
|
@ -72,19 +72,6 @@ public interface Dao<E extends PersistableEntity> {
|
|||
*/
|
||||
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-<code>null</code>
|
||||
* 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.
|
||||
*
|
||||
|
|
|
@ -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<E extends PersistableEntity> 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) {
|
||||
|
|
Loading…
Reference in New Issue