Skip to content

Commit

Permalink
DSC-1496 fix lazy initialization traversing comms/colls
Browse files Browse the repository at this point in the history
  • Loading branch information
abollini committed Jan 20, 2024
1 parent ba6cdbf commit c706135
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,18 @@ public void applyFiltersAllItems(Context context) throws Exception {
@Override
public void applyFiltersCommunity(Context context, Community community)
throws Exception { //only apply filters if community not in skip-list
// ensure that the community is attached to the current hibernate session
// as we are committing after each item (handles, sub-communties and
// collections are lazy attributes)
community = context.reloadEntity(community);
if (!inSkipList(community.getHandle())) {
List<Community> subcommunities = community.getSubcommunities();
for (Community subcommunity : subcommunities) {
applyFiltersCommunity(context, subcommunity);
}

// ensure that the community is attached to the current hibernate session
// as we are committing after each item
community = context.reloadEntity(community);
List<Collection> collections = community.getCollections();
for (Collection collection : collections) {
applyFiltersCollection(context, collection);
Expand All @@ -148,6 +154,9 @@ public void applyFiltersCommunity(Context context, Community community)
@Override
public void applyFiltersCollection(Context context, Collection collection)
throws Exception {
// ensure that the collection is attached to the current hibernate session
// as we are committing after each item (handles are lazy attributes)
collection = context.reloadEntity(collection);
//only apply filters if collection not in skip-list
if (!inSkipList(collection.getHandle())) {
Iterator<Item> itemIterator = itemService.findAllByCollection(context, collection);
Expand Down

0 comments on commit c706135

Please sign in to comment.