-->
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: Realtion 1--N .. take a list of subset element
PostPosted: Tue Sep 12, 2006 7:05 am 
Beginner
Beginner

Joined: Thu Apr 20, 2006 11:51 am
Posts: 44
Hello
I've one relation 1:n
Person 1------->N Address
Person (name, addresses(set))
Address (descripiption, value)

Now I want to take a List of Person that contains Address with 'value>50'

I do 4example:

form Person where addresses.value > '50'

The set is lazy false.
A Person is loaded from DB if it contains an Address with a value>50.
The problem is that the Set of Address contains all the Address associated to the Person! I want that the Person in the list contains a Set of only the Address with value>50 and not all the associated Address.

In this moment I take this list

LIST
    -----Person ----- Address ("AAA", 55);
        ----- Address ("BBB", 10); (I don't want this)
    -----Person ----- Address ("DDD", 144);
        ----- Address ("DDD", 442);
        ----- Address ("EEE", 4); (I don't want this)

I want a list like

LIST
    -----Person ----- Address ("AAA", 55);

    -----Person ----- Address ("DDD", 144);
        ----- Address ("DDD", 442);



What's the method to do this with Hibernate?
Thanks a lot
Martina


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 12, 2006 7:24 am 
Newbie

Joined: Tue Sep 12, 2006 5:16 am
Posts: 5
Location: Ukraine
You should do it yourself by query. Or another way is to make the class extending list with the method that implements this functionality (selecting the addresses with value>50). The second one is much less preferable. It is acceptable only with lazy="false".


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 12, 2006 8:35 am 
Beginner
Beginner

Joined: Thu Apr 20, 2006 11:51 am
Posts: 44
I don't want to do work that hibernate can do for me.
Quote:
You should do it yourself by query

What do you mean? At least 2 query to take a simple list of Student with Address that satisfy the >50 ?
Quote:
Or another way is to make the class extending list with the method that implements this functionality

I don't want this "functionality" inside my class. It's a specific query for a specific scope not common.
There isn't another way via hibernate?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 12, 2006 10:38 am 
Newbie

Joined: Tue Sep 12, 2006 5:16 am
Posts: 5
Location: Ukraine
Try filters. Maybe they'd help.


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.