]> SALOME platform Git repositories - tools/siman.git/commitdiff
Salome HOME
SaveOrUpdate is introduced in DAO and is used for user creation.
authorrkv <rkv@opencascade.com>
Mon, 26 Nov 2012 08:42:46 +0000 (08:42 +0000)
committerrkv <rkv@opencascade.com>
Mon, 26 Nov 2012 08:42:46 +0000 (08:42 +0000)
Workspace/Siman-Common/src/org/splat/dal/dao/kernel/AbstractGenericDAOImpl.java
Workspace/Siman-Common/src/org/splat/dal/dao/kernel/GenericDAO.java
Workspace/Siman-Common/src/org/splat/service/UserServiceImpl.java
Workspace/Siman-Common/src/test/splat/service/TestScenarioService.java

index b1276d265a3a88ed8444973f45a544b72398a2f8..c30ed28ba70cfe9282d99bf675c1e42bff49a62b 100644 (file)
@@ -47,6 +47,17 @@ public abstract class AbstractGenericDAOImpl<T, PK extends Serializable> extends
                return (PK) getSession().save(newInstance);
        }
 
+       /**
+        * Persist the newInstance object into database.
+        * 
+        * @param newInstance
+        *            new object as a transient instance
+        */
+       @SuppressWarnings(UNCHECKED)
+       public void saveOrUpdate(final T newInstance) {
+               getSession().saveOrUpdate(newInstance);
+       }
+
        /**
         * Retrieve an object that was previously persisted to the database using the indicated id as primary key.
         * 
index 415ec25e8af878d8480abb4452215b6b0d661b90..fef4140d0e9e04202f7322fff67e70999add1526 100644 (file)
@@ -37,6 +37,14 @@ public interface GenericDAO<T, PK extends Serializable> {
         */
        PK create(T newInstance);
 
+       /**
+        * Persist the newInstance object into database.
+        * 
+        * @param newInstance
+        *            new object as a transient instance
+        */
+       public void saveOrUpdate(final T newInstance);
+       
        /**
         * Retrieve an object that was previously persisted to the database using the indicated id as primary key.
         * 
index 5b7848ff3e7d6883c57f5de92e27f5ef99b87138..6c672317b4a5c7ccf6deefc2b7e8164948ff05a1 100644 (file)
@@ -72,9 +72,9 @@ public class UserServiceImpl implements UserService {
                // and to avoid th exception:
                // org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the
                // session: [org.splat.dal.bo.kernel.Role#simer]
-               getUserDAO().merge(nuser);
+               getUserDAO().saveOrUpdate(nuser);
                
-               getUserDAO().create(nuser);
+               //getUserDAO().create(nuser);
                return nuser;
        }
 
index 4be263288c0a933929309c49a8504beb429789e0..39d000f48ef1d02a6a9a38a14ab48ddd6669a5fa 100644 (file)
@@ -19,11 +19,11 @@ import java.util.List;
 
 import org.splat.dal.bo.kernel.User;
 import org.splat.dal.bo.som.Document;
+import org.splat.dal.bo.som.Document.Properties;
 import org.splat.dal.bo.som.DocumentType;
 import org.splat.dal.bo.som.Publication;
 import org.splat.dal.bo.som.Scenario;
 import org.splat.dal.bo.som.Study;
-import org.splat.dal.bo.som.Document.Properties;
 import org.splat.dal.dao.som.Database;
 import org.splat.dal.dao.som.ScenarioDAO;
 import org.splat.kernel.InvalidPropertyException;
@@ -40,8 +40,8 @@ import org.splat.service.dto.DocumentDTO;
 import org.splat.service.dto.FileDTO;
 import org.splat.service.dto.StepDTO;
 import org.splat.service.technical.ProjectSettingsService;
-import org.splat.service.technical.RepositoryService;
 import org.splat.service.technical.ProjectSettingsService.Step;
+import org.splat.service.technical.RepositoryService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.orm.hibernate3.HibernateTemplate;