I am using EJB 3.0 entity beans and I have a specific requirement. I need to modify the named query at the run time like add some extra search criteria just before the actual execution. This needs to be done at the framework lavel so that developer do not care about it.
I don't think you can. A named query is constant. You can call entityManager.createNativeQuery().
If you know the changes at deploy time, you can create multiple named queries. If not, you need something more dynamic. If you expand on the requirement, we may be able to suggest other approaches.
The requirement is simple. For each query being executed I want to put some restrictions depending upon the security constraints. For example in a accounting system, the logged in user has access to a set of departments, and this user should only see the Employees in that department. Now instead of putting department filter criteria in each query, I want to modify all the queries to add this criteria at the end(just before execution) depending upon the user access.