Преглед изворни кода

Change createOrUpdate() to use Hibernate session.saveOrUpdate().

Matthew Porter пре 20 година
родитељ
комит
2f2c6bc3d8

+ 3 - 5
domain/src/main/java/org/acegisecurity/domain/hibernate/DaoHibernate.java

@@ -46,6 +46,7 @@ import java.util.List;
  * {@link Dao} implementation that uses Hibernate for persistence.
  *
  * @author Ben Alex
+ * @author Matthew Porter
  * @version $Id$
  */
 public class DaoHibernate extends HibernateDaoSupport implements Dao,
@@ -74,12 +75,9 @@ public class DaoHibernate extends HibernateDaoSupport implements Dao,
 
     public PersistableEntity createOrUpdate(PersistableEntity value) {
         Assert.notNull(value);
+        getHibernateTemplate().saveOrUpdate(value);
 
-        if (value.getInternalId() == null) {
-            return create(value);
-        } else {
-            return update(value);
-        }
+        return readId(value.getInternalId());
     }
 
     public void delete(PersistableEntity value) {