-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Using criteria with <any> mapping, constraining on typ
PostPosted: Mon Apr 06, 2009 6:58 pm 
Newbie

Joined: Fri Apr 03, 2009 4:34 pm
Posts: 1
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?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.