In my program I need to give users permissions on entities of a certain type (lets call the type Organization). The problem is that all my server methods get ids of entities, and I need to somehow verify that an unallowed user does not send an id of an entity he should not access.

I can use an annotation, like this:
public void editOrganization(@Organization Long ids) {...}

and have an interceptor look for @Organization annotations, see who is the currently logged in user, and then check that this user has permission on the organization. Problems with this approach:
-requires adding an attachment to hundreds of methods
-a future developer might forget the annotation, and there is no automatic way for me to detect it.
-some functions in the server get the id of some entity that references an Organization. For example lets say an organization has Employees, and there is a method:

fireEmployee(Long employeeId)

I want that you will be able to call this only if you have permission on the Organization that has that Employee.

I considered using a @FilterDef and @Filter annotation on the Organization entity, but there are problems with this approach:
-my program has lots of native queries and more native queries will be added later. Filters do not work on native queries.
-will not help to cases when an Employee that references the organization is deleted.
-adds lots of performance overhead
-sometimes a server method needs to access an Organization even if the user does not have a permission to it (for example, user has permission on Organization A, which is a suborganization of B. When the user calls deleteOrganization(A) the program should do some calculations regarding B even though the user has no permissions on B).

I will be very grateful if you have a solution or even a hint of a solution