Hi,
I have a Child / Parent relationship.
Only children have a property (ryear). When I do parent.getChildren(), I would like to only receive the children WHERE RYEAR='2003'
I have this condition harcoded in the mapping, it works fine, but I don't want to hardcode it.
I have searched the doc + this forum, but I can't find a way to do it.
I can do session.filter(parent.getChildren(), "WHERE this.ryear='2003'"),
but it's next time I call parent.getChildren(), it will return the full list again.
I want to get the same exact result as specify the WHERE clause in the mapping, but I don't want to hardcode the condition in the mapping.
Is this possible?
Thanks.
Here's my actual mapping:
Code:
<hibernate-mapping>
<class name="model.hibernate.beans.Scientists"
<id name="id" column="SCID" type="string">
<generator class="native"/>
</id>
<property name="firstName" column="FNAME" type="string"/>
<property name="lastName" column="LNAME" type="string"/>
<bag name="ipidOridScid" lazy="false" cascade="all" where="RYEAR='2003'">
<key column="SCID"/>
<one-to-many class="model.hibernate.beans.IpOrSc"/>
</bag>
</class>
<hibernate-mapping>
<class name="model.hibernate.beans.IpOrSc" table="IPID_ORID_SCID">
<composite-id
name="id"
class="model.beans.IpOrScKey"
>
<key-many-to-one name="ipId" class="model.hibernate.beans.IProjects" column="IPID"/>
<key-property name="orId" type="string" column="ORID"/>
<key-many-to-one name="scId" class="model.hibernate.beans.Scientists" column="SCID"/>
</composite-id>
<property name="role" type="string" column="ROLE"/>
<property name="ryear" type="string" column="RYEAR"/>
</class>