I read the version 3 documentation and did not see any explanation for the best way to use the <any> mapping in a Criteria. I want to constrain the join to a particular type of the <any>.
A quick example to demonstrate (similar to the one in the documentation):
<hibernate-mapping>
<class name="Order" table="ORDER">
<id name="id"
column="ID"
type="java.lang.Long">
<generator class="native"/>
</id>
...
<any name="Payment"
id-type="java.lang.Long"
meta-type="string"
cascade="none">
<meta-value value="CASH" class="Cash"/>
<meta-value value="MONEYORDER" class="MoneyOrder"/>
<meta-value value="CHECK" class="Check"/>
<column name="PaymentType" not-null="true"/>
<column name="PaymentID" not-null="true"/>
</any>
</class>
</hibernate-mapping>
<hibernate-mapping>
<class name="Cash" table="CASH">...
</hibernate-mapping>
<hibernate-mapping>
<class name="MoneyOrder" table="MONEYORDER">...
</hibernate-mapping>
<hibernate-mapping>
<class name="Check" table="CHECK">
<id name="id"
column="ID"
type="java.lang.Long">
<generator class="native"/>
</id>
...
<property
name="routingNumber"
type="java.lang.Long"
column="ROUTINGNUMBER"/>
</class>
<hibernate-mapping>
Given Criteria for Order, what would be the best way to use HQL/Criteria to query for all orders where the payment is a Check, and its routing number is 12345?
|