The only way I know to do that, is to execute a query that replaces the EVENT_ID with their order position.
In your example: L=(2,3,1), you should substitute EVENT_ID=2 with 1, EVENT_ID=3 with 2 and EVENT_ID=1 with 3.
The ugly part is how to do that, because it will only work if you are using a database capable of doing that (ie Oracle). In oracle you may use CASE WHEN satatements
An example of JPA/Hibernate query if you use Oracle:
Code:
from Action action
order by (
case
when action.eventId = 2 then 1
when action.eventId = 3 then 2
when action.eventId = 1 then 3
else 4
end
)
An alternative option is to order the result in memory after recovering it.