Has conditionals in table joiners been implemented?

jonwimp wrote:
> 
> Hmm.
> 
> Alright, answering my own questions again, in case anybody/I looks at the
> mailing list archives in 
> future.
> 
> Without conditionals (like "fieldA = 'SOME LITERAL') in table joiners, I
> have to fall back on a 
> huge cross-product.
> 
> While a huge and indiscriminately-built cross-product does work for my
> query, the huge 
> cross-product is semantically wrong/incomplete. In other words, my query
> is needed to make the 
> cross-product's definition complete. Obviously, any errors in the query
> will completely change the 
> semantics for the cross-product.
> 
> Hopefully RDBMSs optimize correctly when joiner conditionals are put into
> the "WHERE" clause. I 
> would guess so, since such optimization is straightforward. If that isn't
> the case, I'll have to 
> fall back on generating full lists (rather than using EntityListIterator).
> 
> Jonathon
> 
> Jonathon -- Improov wrote:
>> David,
>> 
>> Yeah, I would've thought that too, definitions should model only static 
>> structure.
>> 
>> Given my first example, I would like to do a query like "find a Group 
>> that has all 3 kinds of members (LEADER, VICE, MEMBER)".
>> 
>> Or even more complex: "find a Group where a/the leader's name is like 
>> Blah, a/the vice's name is like Bleh, and a/the member's name is like 
>> Bluh".
>> 
>> I've having difficulty putting that into a view-entity and generating a 
>> resultant ListIterator with GenericDelegator.
>> 
>> Help? Thanks!
>> 
>> Jonathon
>> 
>> David E Jones wrote:
>>>
>>> In general entity and view entity definitions are meant to model 
>>> structure, not query constraints. Just add your desired constraints to 
>>> the EntityCondition passed into the findByCondition call (or Map for 
>>> findByAnd or whatever).
>>>
>>> -David
>>>
>>>
>>> Jonathon -- Improov wrote:
>>>> Hi Rodrigo,
>>>>
>>>> Are you absolutely sure that works?
>>>>
>>>> First, your suggestion throws an exception. Note that there is no 
>>>> such field as Member.leaderId.
>>>>
>>>> Second, do take a look at SqlJdbcUtil.java method makeFromClause(). 
>>>> That's where you'll see the joins being made. You'll also see that 
>>>> this isn't possible:
>>>>
>>>> "... <table1> JOIN <table2> ON (<table1>.partyId = <table2>.partyId 
>>>> AND <table2>.roleId = 'LEADER') ..."
>>>>
>>>> What is possible is only:
>>>>
>>>> "... <table1> JOIN <table2> ON (<table1>.partyId = <table2>.partyId) 
>>>> ..."
>>>>
>>>> So, to answer my own question, the OFBiz Entity framework doesn't 
>>>> seem to handle what I requested for.
>>>>
>>>> Perhaps I'm not understanding your suggestion? Would you mind 
>>>> indicating whether you are sure the suggestion works or whether it's 
>>>> a mere guess? Thanks.
>>>>
>>>> If you are sure it works, I'll spend more time trying your 
>>>> suggestion. But from first impressions, you may have missed something 
>>>> because it throws an error.
>>>>
>>>> Jonathon
>>>>
>>>> Rodrigo Souza wrote:
>>>>> Add to your code:
>>>>>
>>>>> <key-map field-name="roleId" rel-field-name="leaderId"/>
>>>>>
>>>>> i.e
>>>>>
>>>>>>    <view-link entity-alias="GP" rel-entity-alias="LD" 
>>>>>> rel-optional="true">
>>>>>>      <!-- Where LD.roleId is "LEADER" -->
>>>>>         <key-map field-name=roleId" rel-field-name="leaderId"/>
>>>>>>    </view-link>
>>>>>
>>>>>
>>>>> 2007/8/6, Jonathon -- Improov <j...@improov.com>:
>>>>>> In view-entity(s), is it possible to have conditionals in <relation>?
>>>>>>
>>>>>> For eg, an entity Group can have 3 types of members: "LEADER", 
>>>>>> "VICE" and "MEMBER".
>>>>>>
>>>>>> I've included my thoughts in the crude example below (please ignore 
>>>>>> syntax errors).
>>>>>>
>>>>>> <entity entity-name="Group">
>>>>>>    <field name="groupId"/>
>>>>>> </entity>
>>>>>>
>>>>>> <entity entity-name="Member">
>>>>>>    <field name="memberId"/>
>>>>>>    <field name="groupId"/>
>>>>>>    <field name="roleId"/>
>>>>>>    <relation rel-entity-name="Group">
>>>>>>      <key-map field-name="groupId"/>
>>>>>>    </relation>
>>>>>> </entity>
>>>>>>
>>>>>> <view-entity entity-name="GroupAndMember">
>>>>>>    <member-entity entity-alias="GP" entity-name="Group"/>
>>>>>>    <member-entity entity-alias="LD" entity-name="Member"/>
>>>>>>    <member-entity entity-alias="VC" entity-name="Member"/>
>>>>>>    <member-entity entity-alias="MB" entity-name="Member"/>
>>>>>>    <alias-all entity-alias="GP"/>
>>>>>>    <alias entity-alias="LD" name="leaderId" field-name="memberId"/>
>>>>>>    <alias entity-alias="VC" name="viceId" field-name="memberId"/>
>>>>>>    <alias entity-alias="MB" name="memberId" field-name="memberId"/>
>>>>>>    <view-link entity-alias="GP" rel-entity-alias="LD" 
>>>>>> rel-optional="true">
>>>>>>      <!-- Where LD.roleId is "LEADER" -->
>>>>>>    </view-link>
>>>>>>    <view-link entity-alias="GP" rel-entity-alias="VC" 
>>>>>> rel-optional="true">
>>>>>>      <!-- Where VC.roleId is "VICE" -->
>>>>>>    </view-link>
>>>>>>    <view-link entity-alias="GP" rel-entity-alias="MB" 
>>>>>> rel-optional="true">
>>>>>>      <!-- Where MB.roleId is "MEMBER" -->
>>>>>>    </view-link>
>>>>>> </entity>
>>>>>>
>>>>>> I know that I can simply use different entities for leader, vice 
>>>>>> and member (eg Leader, Vice and
>>>>>> Member). But that would be a little awkward, since all the 3 
>>>>>> entities will have exactly the same
>>>>>> fields (just different roleIds).
>>>>>>
>>>>>> Is the above possible in OFBiz's Entity framework?
>>>>>>
>>>>>> Jonathon
>>>>>>
>>>>>
>>>>>
>>>>
>>>
>>>
>> 
>> 
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Conditions-in-table-joiners-tp12018323p24717097.html
Sent from the OFBiz - User mailing list archive at Nabble.com.

Reply via email to