I'm using Java - Ibatis and mySQL with Flex/Flash on the front-end. I have one requirement that is to be able to dynamically add creterias and table to a query depending on the user role. here is an example
Same object calling same SQL but different result based on role
Role 1 : Fully Access to employees
SELECT *
FROM Employee A
Role 2 : Limited access to employees
SELECT *
FROM Employee A
, SECURE_LIST B
WHERE B.EmployeeID = A.EmployeeID
AND B.ROLE_ID = 'ROLE'
I could use Dynamic SQL
SELECT *
FROM Employee A
<isNotEmpty property="ROLE" >
, SECURE_LIST B
WHERE B.EmployeeID = A.EmployeeID
AND B.ROLE_ID = #ROLE#
</isNotEmpty>
Other ideas?