diff --git a/wise-webapp/src/main/java/com/wisemapping/dao/LabelManagerImpl.java b/wise-webapp/src/main/java/com/wisemapping/dao/LabelManagerImpl.java index 66fbdbb6..57271f19 100644 --- a/wise-webapp/src/main/java/com/wisemapping/dao/LabelManagerImpl.java +++ b/wise-webapp/src/main/java/com/wisemapping/dao/LabelManagerImpl.java @@ -42,7 +42,7 @@ public class LabelManagerImpl @Override public void saveLabel(@NotNull final Label label) { - getSession().save(label); + getSession().persist(label); } private Session getSession() { diff --git a/wise-webapp/src/main/java/com/wisemapping/dao/MindmapManagerImpl.java b/wise-webapp/src/main/java/com/wisemapping/dao/MindmapManagerImpl.java index 0acb46ef..72e23ffa 100644 --- a/wise-webapp/src/main/java/com/wisemapping/dao/MindmapManagerImpl.java +++ b/wise-webapp/src/main/java/com/wisemapping/dao/MindmapManagerImpl.java @@ -87,7 +87,7 @@ public class MindmapManagerImpl @Override public void updateCollaboration(@NotNull Collaboration collaboration) { final Session session = getSession(); - session.save(collaboration); + session.persist(collaboration); } @Override @@ -111,7 +111,7 @@ public class MindmapManagerImpl public void addCollaborator(@NotNull Collaborator collaborator) { final Session session = getSession(); assert collaborator != null : "ADD MINDMAP COLLABORATOR: Collaborator is required!"; - session.save(collaborator); + session.persist(collaborator); } @Override @@ -158,7 +158,7 @@ public class MindmapManagerImpl @Override public void saveMindmap(Mindmap mindMap) { assert mindMap != null : "Save Mindmap: Mindmap is required!"; - getSession().save(mindMap); + getSession().persist(mindMap); } @Override diff --git a/wise-webapp/src/main/java/com/wisemapping/dao/UserManagerImpl.java b/wise-webapp/src/main/java/com/wisemapping/dao/UserManagerImpl.java index ec96d97a..bcb4fbee 100644 --- a/wise-webapp/src/main/java/com/wisemapping/dao/UserManagerImpl.java +++ b/wise-webapp/src/main/java/com/wisemapping/dao/UserManagerImpl.java @@ -25,7 +25,6 @@ import jakarta.annotation.Resource; import org.hibernate.ObjectNotFoundException; import org.hibernate.Session; import org.hibernate.SessionFactory; -import org.hibernate.query.Query; import org.hibernate.query.SelectionQuery; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -48,9 +47,8 @@ public class UserManagerImpl this.passwordEncoder = passwordEncoder; } - @SuppressWarnings("unchecked") public List getAllUsers() { - return getSession().createQuery("from com.wisemapping.model.User user").list(); + return getSession().createSelectionQuery("from com.wisemapping.model.User user", User.class).getResultList(); } private Session getSession() { @@ -63,10 +61,10 @@ public class UserManagerImpl public User getUserBy(@NotNull final String email) { User user = null; - var query = getSession().createQuery("from com.wisemapping.model.User colaborator where email=:email"); + SelectionQuery query = getSession().createSelectionQuery("from com.wisemapping.model.User colaborator where email=:email",User.class); query.setParameter("email", email); - final List users = query.list(); + final List users = query.getResultList(); if (users != null && !users.isEmpty()) { assert users.size() == 1 : "More than one user with the same email!"; user = users.get(0); @@ -113,7 +111,7 @@ public class UserManagerImpl } else { user.setPassword(""); } - getSession().saveOrUpdate(user); + getSession().persist(user); } @Override @@ -123,7 +121,7 @@ public class UserManagerImpl // Migrate from previous temporal collab to new user ... final Session session = getSession(); collaborator.setEmail(collaborator.getEmail() + "_toRemove"); - session.saveOrUpdate(collaborator); + session.merge(collaborator); session.flush(); // Save all new... @@ -147,7 +145,7 @@ public class UserManagerImpl public void auditLogin(@NotNull AccessAuditory accessAuditory) { assert accessAuditory != null : "accessAuditory is null"; - getSession().save(accessAuditory); + getSession().persist(accessAuditory); } public void updateUser(@NotNull User user) { @@ -159,7 +157,7 @@ public class UserManagerImpl user.setPassword(passwordEncoder.encode(user.getPassword())); } - getSession().update(user); + getSession().merge(user); } public User getUserByActivationCode(long code) {