-->
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.  [ 2 posts ] 
Author Message
 Post subject: Need help on HQL
PostPosted: Sun Jan 21, 2007 7:40 pm 
Newbie

Joined: Sun Jan 21, 2007 7:21 pm
Posts: 2
With the following mapping xml, I would like to retreive the order and order_detail inside the order object that are backorder more than 30 days. I can use the where clause in the mapping file to hard code the 30 days. But is it possible to make this dynamic ?

i.e. order 1 has 50 order_details. 20 of the order_details are more than 30 days back order.

After retrieve the order object, when I query the size of order_details, I would want 20 of the order details, not 50.

Order order = (Order) getSession().get("com.gts.transferobjects.Order", new Long(1));

System.out.println("size of order detail = " + order.getOrderDetails.size();


<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!--
Mapping file autogenerated by MyEclipse - Hibernate Tools
-->
<hibernate-mapping>
<class name="com.gts.transferobjects.order" table="ORDER" >
<id name="dealId" type="java.lang.Long">
<column name="DEAL_ID" precision="9" scale="0" />
<generator class="sequence">
<param name="sequence">order_seq</param>
</generator>
</id>
<timestamp name="updatedDate" column="UPDATED_DATE"
access="field">
</timestamp>
<property name="companyId" type="java.lang.Long">
<column name="TRUST_COMPANY_ID" precision="9" scale="0" not-null="true" />
</property>
<property name="name" type="java.lang.String">
<column name="NAME" length="150" not-null="true" />
</property>
<property name="transactionAbbreviation" type="java.lang.String">
<column name="TRANSACTION_ABBREVIATION" length="10" />
</property>
<property name="principalAmount" type="java.lang.Double">
<column name="PRINCIPAL_AMOUNT" not-null="true" />
</property>
<property name="offeredProspectusBoolean" type="yes_no">
<column name="IS_OFFERED_PROSPECTUS" length="1" not-null="true" />
</property>
<property name="variablePayNoteBoolean" type="yes_no">
<column name="IS_VARIABLE_PAY_NOTE" length="1" not-null="true" />
</property>
<property name="interConduitBoolean" type="yes_no">
<column name="IS_INTER_CONDUIT" length="1" not-null="true" />
</property>
<property name="nonThirdPartyBoolean" type="yes_no">
<column name="IS_NON_THIRD_PARTY" length="1" not-null="true" />
</property>
<property name="closingDate" type="java.util.Date">
<column name="CLOSING_DATE" length="7" />
</property>
<property name="discontinuedYyyymm" type="java.lang.Long">
<column name="DISCONTINUED_YYYYMM" precision="6" scale="0" />
</property>
<property name="createdDate" type="java.util.Date"
update="false">
<column name="CREATED_DATE" length="7" />
</property>
<set name="orderDetail" inverse="true">
<key>
<column name="ORDER_ID" precision="9" scale="0" />
</key>
<one-to-many
class="com.gts.transferobjects.OrderDetails" />
</set>
</class>
</filter-def>

</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 22, 2007 10:49 am 
Regular
Regular

Joined: Mon Jan 22, 2007 10:32 am
Posts: 101
Hi,

I am also new to hibernate but I think you can use the concept of filters to restrict the members of a collection.

http://www.hibernate.org/hib_docs/v3/re ... e/#filters


Moreover filter can contain a parameter and value of this parameter can be set on every invocation.


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

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.