Skip to content

Conversation

@BartChris
Copy link
Collaborator

@BartChris BartChris commented Dec 8, 2025

Adresses #5813 (But no full fix of the described memory usage since this probably requires more changes)

As outlined in #5813 (comment) bidrectional access to the non owning side of a relation can be problematic if the collections are too large. I would prefer if we remove the collection property.

@OneToMany(mappedBy = "processingUser", cascade = CascadeType.PERSIST)
private List<Task> processingTasks;

to not encourage access to and hydration of potential large collections. But we use those accessors in tests so i only replaced the application-level usage of it with an HQL query. Since the processingTasks accessor is no longer used at runtime, we do not need to maintain manual synchronization between both sides of the association.

@BartChris BartChris marked this pull request as ready for review December 8, 2025 13:02
@BartChris BartChris changed the title Remove reliance on bidirectional association Remove reliance on bidirectional association for process tasks Dec 8, 2025
@BartChris BartChris changed the title Remove reliance on bidirectional association for process tasks Remove reliance on bidirectional association in task–user relation Dec 8, 2025
* @param user the processing user
* @return list of tasks in progress for the given user
*/
public List<Task> getTasksInProgress(User user) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a question: Would an additional restriction to the used client of the current user not even more helpful? If an user is assigned to more clients than this list here would include all the tasks over all clients and not only the tasks of the current used client in the UI.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, might be useful.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have not filtered by client before, maybe this is not necessary, as this method is only called in special places.

* @return list of tasks in progress for the given user
*/
public List<Task> getTasksInProgress(User user) {
String hql = "FROM Task t WHERE t.processingUser = :user "
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Limiting / restrict the task list to tasks where the user is set as processing user is may to restrictive as not necessary the user who need this list as worked on this task. I did not even see such restriction in the former place where only assigned processes to the task (non null) and task state in progress the restrictions are.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, i have to think about that.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just noticed that this method is mostly used for emptiness checks; we can probably optimize: If only existence is checked, we do not need to retrieve all the tasks and should do an existence check.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not even see such restriction in the former place

return user.getProcessingTasks().stream()

I think establishing the stream in that way also limited the tasks down to those the user is actually assigned to before.

@BartChris BartChris force-pushed the task-processing-user-refactor branch from f7925b8 to 4abe94b Compare December 8, 2025 15:55
@BartChris
Copy link
Collaborator Author

I refactored more to make it more efficient.

@BartChris BartChris force-pushed the task-processing-user-refactor branch from 4abe94b to d8f8aab Compare December 8, 2025 15:58
<h:panelGroup styleClass="action"
rendered="#{SecurityAccessController.hasAuthorityToUnassignTasks()}"
title="#{empty UserForm.getTasksInProgress(item) ? msgs.userWithoutTasks : msgs.unassignTasks}">
title="#{UserForm.hasTasksInProgress(item) ? msgs.unassignTasks : msgs.userWithoutTasks}">
Copy link
Collaborator Author

@BartChris BartChris Dec 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could be that the user list also benefits from the more efficient checks.

@BartChris BartChris changed the title Remove reliance on bidirectional association in task–user relation Remove reliance on bidirectional association in task-user relation Dec 8, 2025
@BartChris BartChris mentioned this pull request Dec 18, 2025
@BartChris BartChris marked this pull request as draft December 18, 2025 10:29
@BartChris
Copy link
Collaborator Author

Should be rebased on #6803

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants