wood burning stoves 2.0*
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 Android Security Essentials Live Lessons this week in the Android 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?
wood burning stoves
subject: Hibernate Criteria with a one-to-many association
Similar Threads
Runtime intermediate storage - Design Problem
How to handle this large result set
Hibernate Select - Criteria with a Date
Complicated SQL query help
explanation on RowMapper's mapRow method