wood burning stoves
The moose likes Object Relational Mapping and the fly likes Hibernate Criteria with a one-to-many association Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate Criteria with a one-to-many association" Watch "Hibernate Criteria with a one-to-many association" New topic

Hibernate Criteria with a one-to-many association

Caleb TheChosen

Joined: Sep 11, 2011
Posts: 1

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?
I agree. Here's the link: http://aspose.com/file-tools
subject: Hibernate Criteria with a one-to-many association
jQuery in Action, 3rd edition