From b8d79dc804f5ca062586c7a3d27ec87f22db6939 Mon Sep 17 00:00:00 2001 From: srosse <none@none> Date: Fri, 9 Jan 2015 08:48:46 +0100 Subject: [PATCH] OO-1379: reload the base group to prevent lazy loading issues --- .../org/olat/group/manager/BusinessGroupServiceImpl.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/olat/group/manager/BusinessGroupServiceImpl.java b/src/main/java/org/olat/group/manager/BusinessGroupServiceImpl.java index ae5585e2ce8..9ded82e7b70 100644 --- a/src/main/java/org/olat/group/manager/BusinessGroupServiceImpl.java +++ b/src/main/java/org/olat/group/manager/BusinessGroupServiceImpl.java @@ -1502,6 +1502,7 @@ public class BusinessGroupServiceImpl implements BusinessGroupService, UserDataD public void addResourcesTo(List<BusinessGroup> groups, List<RepositoryEntry> resources) { if(groups == null || groups.isEmpty()) return; if(resources == null || resources.isEmpty()) return; + List<Group> baseGroupKeys = new ArrayList<Group>(); for(BusinessGroup group:groups) { @@ -1511,6 +1512,11 @@ public class BusinessGroupServiceImpl implements BusinessGroupService, UserDataD //check for duplicate entries List<RepositoryEntryToGroupRelation> relations = repositoryEntryRelationDao.getRelations(baseGroupKeys); for(BusinessGroup group:groups) { + //reload the base group to prevent lazy loading exception + Group baseGroup = businessGroupRelationDAO.getGroup(group); + if(baseGroup == null) { + continue; + } for(RepositoryEntry re:resources) { boolean found = false; for(RepositoryEntryToGroupRelation relation:relations) { @@ -1519,7 +1525,7 @@ public class BusinessGroupServiceImpl implements BusinessGroupService, UserDataD } } if(!found) { - addResourceTo(group, re); + repositoryEntryRelationDao.createRelation(baseGroup, re); } } } -- GitLab