mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-15 03:07:55 +01:00
Change save
This commit is contained in:
parent
2bc9d41e2f
commit
eddd6899db
@ -42,7 +42,7 @@ public class LabelManagerImpl
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void saveLabel(@NotNull final Label label) {
|
public void saveLabel(@NotNull final Label label) {
|
||||||
getSession().save(label);
|
getSession().persist(label);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Session getSession() {
|
private Session getSession() {
|
||||||
|
@ -87,7 +87,7 @@ public class MindmapManagerImpl
|
|||||||
@Override
|
@Override
|
||||||
public void updateCollaboration(@NotNull Collaboration collaboration) {
|
public void updateCollaboration(@NotNull Collaboration collaboration) {
|
||||||
final Session session = getSession();
|
final Session session = getSession();
|
||||||
session.save(collaboration);
|
session.persist(collaboration);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -111,7 +111,7 @@ public class MindmapManagerImpl
|
|||||||
public void addCollaborator(@NotNull Collaborator collaborator) {
|
public void addCollaborator(@NotNull Collaborator collaborator) {
|
||||||
final Session session = getSession();
|
final Session session = getSession();
|
||||||
assert collaborator != null : "ADD MINDMAP COLLABORATOR: Collaborator is required!";
|
assert collaborator != null : "ADD MINDMAP COLLABORATOR: Collaborator is required!";
|
||||||
session.save(collaborator);
|
session.persist(collaborator);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -158,7 +158,7 @@ public class MindmapManagerImpl
|
|||||||
@Override
|
@Override
|
||||||
public void saveMindmap(Mindmap mindMap) {
|
public void saveMindmap(Mindmap mindMap) {
|
||||||
assert mindMap != null : "Save Mindmap: Mindmap is required!";
|
assert mindMap != null : "Save Mindmap: Mindmap is required!";
|
||||||
getSession().save(mindMap);
|
getSession().persist(mindMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -25,7 +25,6 @@ import jakarta.annotation.Resource;
|
|||||||
import org.hibernate.ObjectNotFoundException;
|
import org.hibernate.ObjectNotFoundException;
|
||||||
import org.hibernate.Session;
|
import org.hibernate.Session;
|
||||||
import org.hibernate.SessionFactory;
|
import org.hibernate.SessionFactory;
|
||||||
import org.hibernate.query.Query;
|
|
||||||
import org.hibernate.query.SelectionQuery;
|
import org.hibernate.query.SelectionQuery;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
@ -48,9 +47,8 @@ public class UserManagerImpl
|
|||||||
this.passwordEncoder = passwordEncoder;
|
this.passwordEncoder = passwordEncoder;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public List<User> getAllUsers() {
|
public List<User> 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() {
|
private Session getSession() {
|
||||||
@ -63,10 +61,10 @@ public class UserManagerImpl
|
|||||||
public User getUserBy(@NotNull final String email) {
|
public User getUserBy(@NotNull final String email) {
|
||||||
User user = null;
|
User user = null;
|
||||||
|
|
||||||
var query = getSession().createQuery("from com.wisemapping.model.User colaborator where email=:email");
|
SelectionQuery<User> query = getSession().createSelectionQuery("from com.wisemapping.model.User colaborator where email=:email",User.class);
|
||||||
query.setParameter("email", email);
|
query.setParameter("email", email);
|
||||||
|
|
||||||
final List<User> users = query.list();
|
final List<User> users = query.getResultList();
|
||||||
if (users != null && !users.isEmpty()) {
|
if (users != null && !users.isEmpty()) {
|
||||||
assert users.size() == 1 : "More than one user with the same email!";
|
assert users.size() == 1 : "More than one user with the same email!";
|
||||||
user = users.get(0);
|
user = users.get(0);
|
||||||
@ -113,7 +111,7 @@ public class UserManagerImpl
|
|||||||
} else {
|
} else {
|
||||||
user.setPassword("");
|
user.setPassword("");
|
||||||
}
|
}
|
||||||
getSession().saveOrUpdate(user);
|
getSession().persist(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -123,7 +121,7 @@ public class UserManagerImpl
|
|||||||
// Migrate from previous temporal collab to new user ...
|
// Migrate from previous temporal collab to new user ...
|
||||||
final Session session = getSession();
|
final Session session = getSession();
|
||||||
collaborator.setEmail(collaborator.getEmail() + "_toRemove");
|
collaborator.setEmail(collaborator.getEmail() + "_toRemove");
|
||||||
session.saveOrUpdate(collaborator);
|
session.merge(collaborator);
|
||||||
session.flush();
|
session.flush();
|
||||||
|
|
||||||
// Save all new...
|
// Save all new...
|
||||||
@ -147,7 +145,7 @@ public class UserManagerImpl
|
|||||||
|
|
||||||
public void auditLogin(@NotNull AccessAuditory accessAuditory) {
|
public void auditLogin(@NotNull AccessAuditory accessAuditory) {
|
||||||
assert accessAuditory != null : "accessAuditory is null";
|
assert accessAuditory != null : "accessAuditory is null";
|
||||||
getSession().save(accessAuditory);
|
getSession().persist(accessAuditory);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateUser(@NotNull User user) {
|
public void updateUser(@NotNull User user) {
|
||||||
@ -159,7 +157,7 @@ public class UserManagerImpl
|
|||||||
user.setPassword(passwordEncoder.encode(user.getPassword()));
|
user.setPassword(passwordEncoder.encode(user.getPassword()));
|
||||||
}
|
}
|
||||||
|
|
||||||
getSession().update(user);
|
getSession().merge(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
public User getUserByActivationCode(long code) {
|
public User getUserByActivationCode(long code) {
|
||||||
|
Loading…
Reference in New Issue
Block a user