-->
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.  [ 3 posts ] 
Author Message
 Post subject: One-to-many Relationship limitation problem
PostPosted: Wed Feb 02, 2011 12:52 pm 
Newbie

Joined: Wed Feb 02, 2011 12:31 pm
Posts: 3
Location: München, Germany
Hello,
I have problem with one-to-many relationships.

Situation:

I have a table and class called "orders" and a lot of order items, which are related with orders using a foreign key. The class orders has got a collection with all order items.

What I want to do:

Now I want to load a specific order via an order number (primary key). Usually the collection of order items is filled with ALL order items. But I don't want that. I want the collection to be filled only with order items of a special amount. So I want to limit the loading of the one-to-many relationship.

Normally this is no good idea (what, if I save the order?), but this is read-only. And I only want to perform one single query.

Does anyone have an idea how to do this?

The classes are something like this

Code:
public class Order {
         private Long orderId;
         private Date date;
         private Set<OrderItem> orderItems;
//...
}

public class OrderItem {

       private Double amount;
       private String itemText;
    // ...
}


Top
 Profile  
 
 Post subject: Re: One-to-many Relationship limitation problem
PostPosted: Wed Feb 02, 2011 12:55 pm 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
Seems like this should be doable with a filter: http://docs.jboss.org/hibernate/core/3. ... te-filters


Top
 Profile  
 
 Post subject: Re: One-to-many Relationship limitation problem
PostPosted: Wed Feb 02, 2011 1:41 pm 
Newbie

Joined: Wed Feb 02, 2011 12:31 pm
Posts: 3
Location: München, Germany
nordborg wrote:
Seems like this should be doable with a filter: http://docs.jboss.org/hibernate/core/3. ... te-filters


Thanx a lot. This really helped me out!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.