I am generating the SQL query using CriteriaBuilder which is as
SELECT * FROM TABLE WHERE product_id = \'8\' AND ( STATE = \'TESTED\' OR (