-->
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.  [ 4 posts ] 
Author Message
 Post subject: Limit Collection size in 1-n relationship with ejb-ql
PostPosted: Tue Aug 17, 2010 11:45 am 
Newbie

Joined: Tue Aug 17, 2010 11:42 am
Posts: 3
Hi I got a problem with ejb-ql

I have objects, say Partners which contain a collection of Orders.
I want to retrieve all Partners which have an order in the "open" sate.
I must restrict the number of orders which are returned. Only those in the "open" state should be returned.

How can I do this with ejb-ql?


Top
 Profile  
 
 Post subject: Re: Limit Collection size in 1-n relationship with ejb-ql
PostPosted: Tue Aug 17, 2010 11:56 am 
Beginner
Beginner

Joined: Wed Nov 21, 2007 10:24 am
Posts: 25
Do you always want just the open orders to be returned? i.e. when you do partner.getOrders() do you only want it to return open ones? If so, you might look at http://docs.jboss.org/hibernate/stable/ ... ec-filters

I believe that's what you want for filtering a collection.


Top
 Profile  
 
 Post subject: Re: Limit Collection size in 1-n relationship with ejb-ql
PostPosted: Wed Aug 18, 2010 6:39 am 
Newbie

Joined: Tue Aug 17, 2010 11:42 am
Posts: 3
Tank you kjordan2001
I looked at the filters, but either I don't get something or they do not suit my needs.

I don't want to return the orders, I want to return the Partners. But within the partners I only want the Orders sub collection, which have the "open" state.

Filters for what I understand give you another way to write a where clause. I.e. you reduce the size of your collection. In my case the collection I could reduce is the Partner collection, not the Order collection within the Partners :(

The only way I see for now is building a DTO, but I will have to iterate over all my order collection to define if they are in the "open" state (either by hand or via filter)


Top
 Profile  
 
 Post subject: Re: Limit Collection size in 1-n relationship with ejb-ql
PostPosted: Wed Aug 18, 2010 9:19 am 
Beginner
Beginner

Joined: Wed Nov 21, 2007 10:24 am
Posts: 25
fan wrote:
Tank you kjordan2001
I looked at the filters, but either I don't get something or they do not suit my needs.

I don't want to return the orders, I want to return the Partners. But within the partners I only want the Orders sub collection, which have the "open" state.

Filters for what I understand give you another way to write a where clause. I.e. you reduce the size of your collection. In my case the collection I could reduce is the Partner collection, not the Order collection within the Partners :(

The only way I see for now is building a DTO, but I will have to iterate over all my order collection to define if they are in the "open" state (either by hand or via filter)

That's what filters do, if you look at:
Code:
@OneToMany
    @JoinTable
    //filter on the target entity table
    @Filter(name="betweenLength", condition=":minLength <= length and :maxLength >= length")
    //filter on the association table
    @FilterJoinTable(name="security", condition=":userlevel >= requredLevel")
    public Set<Forest> getForests() { ... }


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