Hi I have a question about bag mapping.
class Parent { private long id;//Primary key private long dept_id ; }
class Parent { private long id;//Primary key private long dept_id ; private Parent parent; }
the simplest forms of my classes. I have a bag collection in parent mapping like below;
<bag name="children" table="TAB_CHILDREN" order-by="ID desc" cascade="all-delete-orphan" inverse="true" > <key column="PARENT_ID"/> <one-to-many class="Parent"/> </bag> parent.getchildren(); method generates the select * from tab_children where parent_id= ? ; parent's id as parameter; I want the dept_id of these tables match , i mean parent.getchildren() method generates this sql ; select * from tab_children where parent_id= ? and dept_id =? ; parent's id as first parameter and parent's dept_id as second parameter;
I tried to use ' where ' property of bag but i coludn't pass the dept_id of parent as parameter ; I need this because of performance issues ,We use orcle dB and we have partitioning on dept_id columns so.
how can i get this bag definition generate second sql?
|