-->
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: Hibernate Criteria with a one-to-many association
PostPosted: Mon Sep 12, 2011 1:04 am 
Newbie

Joined: Sat Sep 03, 2011 10:16 am
Posts: 10
Hi,

I have an Order entity (that, well, represnts an order), and each order has a set of DeliveryDates.
I'm trying to implement a search function and show the results in a JFace TableViewer.

I want that for every order that has more than one delivery date, it should be duplicated in the table, but the DeliveryDate column would display the specific delivery date for this instance.

This query is easily done in SQL using a simple join, and the rows are duplicated with a different date for every row.
Since I'm doing a search feature, I'm building the query in steps (depending on what search parameters the user had chosen), so building a query using Criteria is very useful. The problem is, that the result list I get is duplicated (which is OK), but every entity simply contains the same set of DeliveryDates - so I can't print a different date for different rows of the same Order.

Is there any way to do this using Critera? And if not, how can I do it?

Edit: For example, this HQL query seems to do something similar: "select dd.deliveryDate, od from Order as od left join od.deliveryDates dd"


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.