Conditions in table joiners

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
18 messages Options
Reply | Threaded
Open this post in threaded view
|

Conditions in table joiners

jonwimp
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
Reply | Threaded
Open this post in threaded view
|

Re: Conditions in table joiners

Rodrigo Lima-2
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 <[hidden email]>:

> 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
>
Reply | Threaded
Open this post in threaded view
|

Re: Conditions in table joiners

jonwimp
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 <[hidden email]>:
>> 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
>>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: Conditions in table joiners

David E Jones

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 <[hidden email]>:
>>> 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
>>>
>>
>>
>
Reply | Threaded
Open this post in threaded view
|

Re: Conditions in table joiners

jonwimp
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 <[hidden email]>:
>>>> 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
>>>>
>>>
>>>
>>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: Conditions in table joiners

Rodrigo Lima-2
One sample:


List conditions = new ArrayList();
try {
    // List home destque promo
    conditions.add(new EntityExpr("viceId", EntityOperator.EQUALS,
"LEADER"));
   // Others...

   EntityConditionList ecl = new EntityConditionList(conditions,
EntityOperator.AND);
   List results  = delegator.findByCondition("YourViewName", ecl, null,
UtilMisc.toList("viceId"));

.......

2007/8/7, Jonathon -- Improov <[hidden email]>:
> 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 <[hidden email]>:
> >>>> 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
> >>>>
> >>>
> >>>
> >>
> >
> >
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Conditions in table joiners

Rodrigo Lima-2
Or...
conditions.add(new EntityExpr("memberId", EntityOperator.IN, UtilMisc.toList
("LEADER","MEMBER","VICE")));

For all.


2007/8/7, Rodrigo Souza <[hidden email]>:

>
> One sample:
>
>
> List conditions = new ArrayList();
> try {
>     // List home destque promo
>     conditions.add(new EntityExpr("viceId", EntityOperator.EQUALS,
> "LEADER"));
>    // Others...
>
>    EntityConditionList ecl = new EntityConditionList(conditions,
> EntityOperator.AND);
>    List results  = delegator.findByCondition("YourViewName", ecl, null,
> UtilMisc.toList("viceId"));
>
> .......
>
> 2007/8/7, Jonathon -- Improov <[hidden email]>:
> > 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 <[hidden email]>:
> > >>>> 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
> > >>>>
> > >>>
> > >>>
> > >>
> > >
> > >
> >
> >
>
Reply | Threaded
Open this post in threaded view
|

Re: Conditions in table joiners

jonwimp
In reply to this post by Rodrigo Lima-2
Rodrigo,

Thanks, but I think I'm completely confused by your sample. Sorry.

The column alias (not field) "viceId" contains a value in Member.memberId (eg "1234", "5534",
etc), and NOT "LEADER" or "VICE" or "MEMBER".

"LEADER" or "VICE" or "MEMBER" appears in field Member.roleId.

Jonathon

Rodrigo Souza wrote:

> One sample:
>
>
> List conditions = new ArrayList();
> try {
>     // List home destque promo
>     conditions.add(new EntityExpr("viceId", EntityOperator.EQUALS,
> "LEADER"));
>    // Others...
>
>    EntityConditionList ecl = new EntityConditionList(conditions,
> EntityOperator.AND);
>    List results  = delegator.findByCondition("YourViewName", ecl, null,
> UtilMisc.toList("viceId"));
>
> .......
>
> 2007/8/7, Jonathon -- Improov <[hidden email]>:
>> 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 <[hidden email]>:
>>>>>> 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
>>>>>>
>>>>>
>>>
>>
>
>
> ------------------------------------------------------------------------
>
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.5.476 / Virus Database: 269.11.8/940 - Release Date: 8/6/2007 4:53 PM

Reply | Threaded
Open this post in threaded view
|

Re: Conditions in table joiners

jonwimp
In reply to this post by Rodrigo Lima-2
Rodrigo,

Let me repeat the query I want to do: "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".

Your sample doesn't work. Even if you had used the correct field "roleId", it still wouldn't have
worked.

David (Jones). Any help? Please? Thanks.

Jonathon

Rodrigo Souza wrote:

> Or...
> conditions.add(new EntityExpr("memberId", EntityOperator.IN, UtilMisc.toList
> ("LEADER","MEMBER","VICE")));
>
> For all.
>
>
> 2007/8/7, Rodrigo Souza <[hidden email]>:
>> One sample:
>>
>>
>> List conditions = new ArrayList();
>> try {
>>     // List home destque promo
>>     conditions.add(new EntityExpr("viceId", EntityOperator.EQUALS,
>> "LEADER"));
>>    // Others...
>>
>>    EntityConditionList ecl = new EntityConditionList(conditions,
>> EntityOperator.AND);
>>    List results  = delegator.findByCondition("YourViewName", ecl, null,
>> UtilMisc.toList("viceId"));
>>
>> .......
>>
>> 2007/8/7, Jonathon -- Improov <[hidden email]>:
>>> 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 <[hidden email]>:
>>>>>>> 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
>>>>>>>
>>>>>>
>>>>
>>>
>
>
> ------------------------------------------------------------------------
>
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.5.476 / Virus Database: 269.11.8/940 - Release Date: 8/6/2007 4:53 PM

Reply | Threaded
Open this post in threaded view
|

Re: Conditions in table joiners

Rodrigo Lima-2
In reply to this post by jonwimp
Sorry,

Again...

List conditions = new ArrayList();
try {

   // viceId as alias
    conditions.add(new EntityExpr("viceId", EntityOperator.EQUALS,
yourMemberId   ));
   // Others...

   EntityConditionList ecl = new EntityConditionList(conditions,
EntityOperator.AND);
   List results  = delegator.findByCondition("YourViewName", ecl, null, null
);




2007/8/7, Jonathon -- Improov <[hidden email]>:

>
> Rodrigo,
>
> Thanks, but I think I'm completely confused by your sample. Sorry.
>
> The column alias (not field) "viceId" contains a value in Member.memberId(eg "1234", "5534",
> etc), and NOT "LEADER" or "VICE" or "MEMBER".
>
> "LEADER" or "VICE" or "MEMBER" appears in field Member.roleId.
>
> Jonathon
>
> Rodrigo Souza wrote:
> > One sample:
> >
> >
> > List conditions = new ArrayList();
> > try {
> >     // List home destque promo
> >     conditions.add(new EntityExpr("viceId", EntityOperator.EQUALS,
> > "LEADER"));
> >    // Others...
> >
> >    EntityConditionList ecl = new EntityConditionList(conditions,
> > EntityOperator.AND);
> >    List results  = delegator.findByCondition("YourViewName", ecl, null,
> > UtilMisc.toList("viceId"));
> >
> > .......
> >
> > 2007/8/7, Jonathon -- Improov <[hidden email]>:
> >> 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 <[hidden email]>:
> >>>>>> 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
> >>>>>>
> >>>>>
> >>>
> >>
> >
> >
> > ------------------------------------------------------------------------
> >
> > No virus found in this incoming message.
> > Checked by AVG Free Edition.
> > Version: 7.5.476 / Virus Database: 269.11.8/940 - Release Date: 8/6/2007
> 4:53 PM
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Conditions in table joiners

jonwimp
In reply to this post by jonwimp
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 <[hidden email]>:
>>>>> 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
>>>>>
>>>>
>>>>
>>>
>>
>>
>
>

Reply | Threaded
Open this post in threaded view
|

ClassNotFoundException

kurtis shipp
while trying to deploy an application and running it,I got the following from console.log;
   
   
  2007-08-08 05:57:38,875 (main) [    StandardContext.java:3714:ERROR] Error configuring application listener of class org.ofbiz.securityext.login.LoginEventListener
java.lang.ClassNotFoundException: org.ofbiz.securityext.login.LoginEventListener
 at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1355)
 at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1201)
  ..........
   
   
  anyone know how to resolve this?kindly help..
   
  cheers,
  kurtis
   
   

       
---------------------------------
Be a better Globetrotter. Get better travel answers from someone who knows.
Yahoo! Answers - Check it out.
Reply | Threaded
Open this post in threaded view
|

Re: ClassNotFoundException

Gautam Deb-2
Check if build is successful on the ofbiz module

Thanks
Gautam Deb

On 8/8/07, kurtis shipp <[hidden email]> wrote:

>
> while trying to deploy an application and running it,I got the following
> from console.log;
>
>
>   2007-08-08 05:57:38,875 (main) [    StandardContext.java:3714:ERROR]
> Error configuring application listener of class
> org.ofbiz.securityext.login.LoginEventListener
> java.lang.ClassNotFoundException:
> org.ofbiz.securityext.login.LoginEventListener
> at org.apache.catalina.loader.WebappClassLoader.loadClass(
> WebappClassLoader.java:1355)
> at org.apache.catalina.loader.WebappClassLoader.loadClass(
> WebappClassLoader.java:1201)
>   ..........
>
>
>   anyone know how to resolve this?kindly help..
>
>   cheers,
>   kurtis
>
>
>
>
> ---------------------------------
> Be a better Globetrotter. Get better travel answers from someone who
> knows.
> Yahoo! Answers - Check it out.
Reply | Threaded
Open this post in threaded view
|

Re: ClassNotFoundException

kurtis shipp
yea,build was successful without error or warning.
  still wondering what the problem is.
   
  cheers,
  kurtis
   
 

Gautam Deb <[hidden email]> wrote:
  Check if build is successful on the ofbiz module

Thanks
Gautam Deb

On 8/8/07, kurtis shipp wrote:

>
> while trying to deploy an application and running it,I got the following
> from console.log;
>
>
> 2007-08-08 05:57:38,875 (main) [ StandardContext.java:3714:ERROR]
> Error configuring application listener of class
> org.ofbiz.securityext.login.LoginEventListener
> java.lang.ClassNotFoundException:
> org.ofbiz.securityext.login.LoginEventListener
> at org.apache.catalina.loader.WebappClassLoader.loadClass(
> WebappClassLoader.java:1355)
> at org.apache.catalina.loader.WebappClassLoader.loadClass(
> WebappClassLoader.java:1201)
> ..........
>
>
> anyone know how to resolve this?kindly help..
>
> cheers,
> kurtis
>
>
>
>
> ---------------------------------
> Be a better Globetrotter. Get better travel answers from someone who
> knows.
> Yahoo! Answers - Check it out.


       
---------------------------------
Choose the right car based on your needs.  Check out Yahoo! Autos new Car Finder tool.
Reply | Threaded
Open this post in threaded view
|

paymentType list

kurtis shipp
hello,
   
  Am just getting on with OFBiz
  am trying to remove some links for paymentType displayed on accounting main page(main.ftl).
  listed below is a portion that contain a list of links for paymentType
   
  <ul>
  <#list paymentTypes as paymentType>
  <li><a href="<@ofbizUrl>findPayments?lookupFlag=Y&paymentTypeId=${paymentType.paymentTypeId}</@ofbizUrl>">${uiLabelMap.AccountingShowPayments} ${paymentType.get("description",locale)}</a></li>
  </#list>
  </ul>
  </td>
   
  I wish to remove/delete some payment types from the list displayed on accounting main page but do not know where the paymentType list is populated from.
   
   ;
  li><a href="<@ofbizUrl>findPayments?lookupFlag=Y&paymentTypeId=${paymentType.paymentTypeId}</@ofbizUrl>">${uiLabelMap.AccountingShowPayments}
   
  was able to trace the above to accounting AccountingUiLabels.properties where
  AccountingShowPayments= Show Payments
   
   
  but could not figure out
  ${paymentType.get("description",locale)}</a></li>
   
  where is the list populated from?
   
   
  cheers,
  kurtis.

       
---------------------------------
Ready for the edge of your seat? Check out tonight's top picks on Yahoo! TV.
Reply | Threaded
Open this post in threaded view
|

Re: paymentType list--issue resolved

kurtis shipp
well,issue resolved,I got the solution while l was poking around paymentforms.xml.
   
  all I did was to go to webtools and delete the entities that are not needed.
   
  cheers,
  kurtis
   
 

kurtis shipp <[hidden email]> wrote:
  hello,

Am just getting on with OFBiz
am trying to remove some links for paymentType displayed on accounting main page(main.ftl).
listed below is a portion that contain a list of links for paymentType

 
<#list paymentTypes as paymentType>
 
   findPayments?lookupFlag=Y&paymentTypeId=${paymentType.paymentTypeId}">${uiLabelMap.AccountingShowPayments} ${paymentType.get("description",locale)}





I wish to remove/delete some payment types from the list displayed on accounting main page but do not know where the paymentType list is populated from.

;
li>findPayments?lookupFlag=Y&paymentTypeId=${paymentType.paymentTypeId}">${uiLabelMap.AccountingShowPayments}

was able to trace the above to accounting AccountingUiLabels.properties where
AccountingShowPayments= Show Payments


but could not figure out
${paymentType.get("description",locale)}

where is the list populated from?


cheers,
kurtis.


---------------------------------
Ready for the edge of your seat? Check out tonight's top picks on Yahoo! TV.

       
---------------------------------
Got a little couch potato?
Check out fun summer activities for kids.
Reply | Threaded
Open this post in threaded view
|

Re: paymentType list

Scott Gray
In reply to this post by kurtis shipp
Hi Kurtis

I would recommend downloading and watching these videos:
http://docs.ofbiz.org/display/OFBTECH/Framework+Introduction+Videos+and+Diagrams

They will save you countless hours in the long run.

Remember when trying to figure out how a page loads you are best to start
with the controller.xml which and then move on the *Screens.xml which will
show you where most of the data preparation is taking place.

Regards
Scott

On 10/08/07, kurtis shipp <[hidden email]> wrote:

>
> hello,
>
>   Am just getting on with OFBiz
>   am trying to remove some links for paymentType displayed on accounting
> main page(main.ftl).
>   listed below is a portion that contain a list of links for paymentType
>
>   <ul>
>   <#list paymentTypes as paymentType>
>   <li><a href="<@ofbizUrl>findPayments?lookupFlag=Y&paymentTypeId=${
> paymentType.paymentTypeId}</@ofbizUrl>">${
> uiLabelMap.AccountingShowPayments} ${paymentType.get
> ("description",locale)}</a></li>
>   </#list>
>   </ul>
>   </td>
>
>   I wish to remove/delete some payment types from the list displayed on
> accounting main page but do not know where the paymentType list is populated
> from.
>
>    ;
>   li><a href="<@ofbizUrl>findPayments?lookupFlag=Y&paymentTypeId=${
> paymentType.paymentTypeId}</@ofbizUrl>">${
> uiLabelMap.AccountingShowPayments}
>
>   was able to trace the above to accounting AccountingUiLabels.propertieswhere
>   AccountingShowPayments= Show Payments
>
>
>   but could not figure out
>   ${paymentType.get("description",locale)}</a></li>
>
>   where is the list populated from?
>
>
>   cheers,
>   kurtis.
>
>
> ---------------------------------
> Ready for the edge of your seat? Check out tonight's top picks on Yahoo!
> TV.
Reply | Threaded
Open this post in threaded view
|

Re: Conditions in table joiners

snowch
In reply to this post by jonwimp
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">
>>>>>      
>>>>         <key-map field-name=roleId" rel-field-name="leaderId"/>
>>>>>    </view-link>
>>>>
>>>>
>>>> 2007/8/6, Jonathon -- Improov <jonw@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">
>>>>>      
>>>>>    </view-link>
>>>>>    <view-link entity-alias="GP" rel-entity-alias="VC"
>>>>> rel-optional="true">
>>>>>      
>>>>>    </view-link>
>>>>>    <view-link entity-alias="GP" rel-entity-alias="MB"
>>>>> rel-optional="true">
>>>>>      
>>>>>    </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
>>>>>
>>>>
>>>>
>>>
>>
>>
>
>