I'm trying to order a list of entity according to who's logged in and based on the last action done.
For example, i'm logged in as admin A, and in a list of people, i'm doing something in the profile of User C.
The output i need is:
- for admin A: people ordered like this : C - A - B - D -E ...
- for other admins: people ordered like this : A - B - C - D ...
To do so i did a table looking with these attribute:
- id : auto - generated
- adminId
- userId
- DateOfLastAction
With a link OneToMany (one user -> many order) between the 2 tables (mappedBy : userId, inversed by iD) because a given user can have different "DateOfLastAction" according to the adminID who did the action.
Problem now is when i want to order my user by DateOfLastAction, i can't be done because of the OneToMany relationship..
(doing like the given answer in this post)
So the best would be to transform it to a *ToOne realtionship. Would a composite primary key help me? Does someone have any idea of a better design?