I have two tables: company and employees. I am trying to read a company object and the set of employees associated with it. However, I would only like for the employees set associated with the company to contain employee objects that have not been flagged as deleted. Is there a way to set up the mapping files for company or for employees such that employee entries that are flagged as deleted do not get read?
So far I have been able to set up a one-to-many relationship where I read in a company and it gets all the employees associated with the company. I just need to know how to restrict it to only employees that have not been flagged as deleted.
This is the property that is located in the Company.hbm.xml file <set name="employeesSet" table="employees"> <key column="companyID"/> <one-to-many class="Employee" not-found="ignore"/> </set>
In SQL it would be SELECT * FROM employees WHERE isDeleted = 0
I am using a delete flag isDeleted for auditing purposes rather than just delete entries completely out of the database.
Also, I am wondering if it is easier to use HQL for this sort of request versus configuring the mapping file or using criteria query and if anyone has any information on using many-to-many mappings in blazeDS.
|