[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ojb-user
Subject:    Re: collection-descriptor pointing to same table
From:       "Charles N. Harvey III" <charlieh () alloy ! com>
Date:       2004-10-26 15:39:43
Message-ID: 417E6FBF.9060701 () alloy ! com
[Download RAW message or body]

Daniel.
I did write a method in the Account class that retrieves the required
objects.  I was just seeing of OJB could be configured to do it for me.
Oh well.  Thanks again for the help.


Charlie



Daniel Perry said the following on 10/26/2004 11:25 AM:

>So you have an Account with a referrer_id X and you want to get all Accounts
>with referral_id X.
>
>As far as i know a collection-descriptor only allows you to specify the
>child's column to use, not the parents - it uses the primay key of the
>parent.  If there is a way to specify while field to use then please correct
>me!
>
>You could always write a method in the Account class (or a helper class)
>that retrieves the required objects.
>
>Daniel.
>
>  
>
>>-----Original Message-----
>>From: Charles N. Harvey III [mailto:charlieh@alloy.com]
>>Sent: 26 October 2004 16:06
>>To: OJB Users List
>>Subject: Re: collection-descriptor pointing to same table
>>
>>
>>Daniel.
>>Thanks for the tip.  But what if the referral_id is not the account_id.
>>
>>What is actually the case is:
>>
>>ACCOUNT
>>----------
>>account_id
>>referrer_id
>>referral_id
>>
>>SELECT * FROM ACCOUNT WHERE referral_id = 'referrer_id'
>>
>>I wasn't sure how to setup the collection-descriptor.  It seems to only
>>be able to use the ID of the current table
>>
>><collection-descriptor
>>        name="referredAccounts"
>>        element-class-ref="Account"
>>        proxy="true">
>>    <inverse-foreignkey field-ref="???"/>
>></collection-descriptor>
>>
>>If you know of a way for the foreign key to point from referrer_id to
>>referral_id let me know.
>>
>>Thanks again.
>>
>>
>>Charlie
>>
>>
>>
>>Daniel Perry said the following on 10/26/2004 4:24 AM:
>>
>>    
>>
>>>If i'm understanding you, you want an Account to have a
>>>      
>>>
>>List/Collection of
>>    
>>
>>>Accounts?
>>>
>>>That shouldnt be a problem.  Just add a collection descriptor in
>>>      
>>>
>>the normal
>>    
>>
>>>fashion and it will give you that collection:
>>>
>>><collection-descriptor name="children" element-class-ref="Account"
>>>proxy="true">
>>>   <inverse-foreignkey field-ref="referral_id"/>
>>></collection-descriptor>
>>>
>>>You can add a reference descriptor for 'parent' aswell.  Note
>>>      
>>>
>>the proxy will
>>    
>>
>>>stop it loading everything at the same time, and as it's
>>>      
>>>
>>proxying the whole
>>    
>>
>>>collection you dont need to do anything with interfaces, etc.
>>>
>>>Daniel.
>>>
>>>
>>>
>>>
>>>      
>>>
>>>>-----Original Message-----
>>>>From: Charles N. Harvey III [mailto:charlieh@alloy.com]
>>>>Sent: 25 October 2004 20:52
>>>>To: OJB Users List
>>>>Subject: collection-descriptor pointing to same table
>>>>
>>>>
>>>>Hello.
>>>>I have a class/table that has sub collections within itself.
>>>>
>>>>ACCOUNT
>>>>-------
>>>>account_id
>>>>referral_id
>>>>
>>>>SELECT * FROM ACCOUNT WHERE account_id = '10'
>>>>
>>>>But, I need to then get all the ACCOUNTs that account '10' referred.
>>>>
>>>>SELECT * FROM ACCOUNT WHERE referral_id = '10'
>>>>
>>>>That will get me back a collection.  So, can I set up this collection
>>>>as a collection-descriptor?  Will it loop into infinity and make my
>>>>server run out of memory?  I have to get referrals 5 levels deep, so
>>>>I do want this to run a few times, but not too many.
>>>>
>>>>I basically need a tree of ACCOUNTs that have referred other ACCOUNTs.
>>>>This shouldn't be so confusing, yet I am awfully confused.  So if anyone
>>>>has a way to set this up easily (and I know it will be slow) with OJB,
>>>>please let me know.
>>>>
>>>>Thanks a lot.
>>>>
>>>>
>>>>Charlie
>>>>
>>>>
>>>>---------------------------------------------------------------------
>>>>To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>>>For additional commands, e-mail: ojb-user-help@db.apache.org
>>>>
>>>>
>>>>
>>>>
>>>>        
>>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>>For additional commands, e-mail: ojb-user-help@db.apache.org
>>>
>>>
>>>
>>>
>>>
>>>      
>>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>For additional commands, e-mail: ojb-user-help@db.apache.org
>>
>>
>>    
>>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>For additional commands, e-mail: ojb-user-help@db.apache.org
>
>
>
>  
>

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic