Question related to EntityQuery usage

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

Question related to EntityQuery usage

valery chenzo
Hi Pros,

Am new to Ofbiz and am having a hard time coming up with an EntityQuery
statement that can represent this simple SQL statement

"SELECT DISTINCT l.sd, l.sv, r.dt, l.pn FROM LL l, Res r WHERE l.td = ? AND
l.sd = r.id ORDER BY l.sd, l.sv"

LL and Res represent 2 independent entity models in the Ofbiz entity engine.

I will appreciate any help or pointers to documentation on how to do this

Thanks,
Chenzo
Reply | Threaded
Open this post in threaded view
|

Re: Question related to EntityQuery usage

taher
Hi Valery,

I believe the EntityQuery can only operate on one entity/table. To create
the above statement I would suggest to:

- Use the from method which takes a DynamicViewEntity argument and build
your entity dynamically. For more on that read on the DynamicViewEntity (
https://ci.apache.org/projects/ofbiz/site/javadocs/org/ofbiz/entity/model/DynamicViewEntity.html
)
- Create a view entity which joins your entities and then run the
EntityQuery against it.

I hope this helps, Cheers!

Taher Alkhateeb

On Mon, Aug 15, 2016 at 4:30 PM, valery chenzo <[hidden email]>
wrote:

> Hi Pros,
>
> Am new to Ofbiz and am having a hard time coming up with an EntityQuery
> statement that can represent this simple SQL statement
>
> "SELECT DISTINCT l.sd, l.sv, r.dt, l.pn FROM LL l, Res r WHERE l.td = ?
> AND
> l.sd = r.id ORDER BY l.sd, l.sv"
>
> LL and Res represent 2 independent entity models in the Ofbiz entity
> engine.
>
> I will appreciate any help or pointers to documentation on how to do this
>
> Thanks,
> Chenzo
>
Reply | Threaded
Open this post in threaded view
|

Re: Question related to EntityQuery usage

valery chenzo
Thanks very much. I did go with the DynamicViewEntity

> On Aug 15, 2016, at 1:25 PM, Taher Alkhateeb <[hidden email]> wrote:
>
> Hi Valery,
>
> I believe the EntityQuery can only operate on one entity/table. To create
> the above statement I would suggest to:
>
> - Use the from method which takes a DynamicViewEntity argument and build
> your entity dynamically. For more on that read on the DynamicViewEntity (
> https://ci.apache.org/projects/ofbiz/site/javadocs/org/ofbiz/entity/model/DynamicViewEntity.html
> )
> - Create a view entity which joins your entities and then run the
> EntityQuery against it.
>
> I hope this helps, Cheers!
>
> Taher Alkhateeb
>
> On Mon, Aug 15, 2016 at 4:30 PM, valery chenzo <[hidden email]>
> wrote:
>
>> Hi Pros,
>>
>> Am new to Ofbiz and am having a hard time coming up with an EntityQuery
>> statement that can represent this simple SQL statement
>>
>> "SELECT DISTINCT l.sd, l.sv, r.dt, l.pn FROM LL l, Res r WHERE l.td = ?
>> AND
>> l.sd = r.id ORDER BY l.sd, l.sv"
>>
>> LL and Res represent 2 independent entity models in the Ofbiz entity
>> engine.
>>
>> I will appreciate any help or pointers to documentation on how to do this
>>
>> Thanks,
>> Chenzo
>>
Reply | Threaded
Open this post in threaded view
|

Re: Question related to EntityQuery usage

Jacques Le Roux
Administrator
Also Check that you really need DynamicViewEntit. Most of the time you can simply create a "<view-entity". There are 314 examples OOTB

HTH

Jacques


Le 17/08/2016 à 07:31, valery chenzo a écrit :

> Thanks very much. I did go with the DynamicViewEntity
>
>> On Aug 15, 2016, at 1:25 PM, Taher Alkhateeb <[hidden email]> wrote:
>>
>> Hi Valery,
>>
>> I believe the EntityQuery can only operate on one entity/table. To create
>> the above statement I would suggest to:
>>
>> - Use the from method which takes a DynamicViewEntity argument and build
>> your entity dynamically. For more on that read on the DynamicViewEntity (
>> https://ci.apache.org/projects/ofbiz/site/javadocs/org/ofbiz/entity/model/DynamicViewEntity.html
>> )
>> - Create a view entity which joins your entities and then run the
>> EntityQuery against it.
>>
>> I hope this helps, Cheers!
>>
>> Taher Alkhateeb
>>
>> On Mon, Aug 15, 2016 at 4:30 PM, valery chenzo <[hidden email]>
>> wrote:
>>
>>> Hi Pros,
>>>
>>> Am new to Ofbiz and am having a hard time coming up with an EntityQuery
>>> statement that can represent this simple SQL statement
>>>
>>> "SELECT DISTINCT l.sd, l.sv, r.dt, l.pn FROM LL l, Res r WHERE l.td = ?
>>> AND
>>> l.sd = r.id ORDER BY l.sd, l.sv"
>>>
>>> LL and Res represent 2 independent entity models in the Ofbiz entity
>>> engine.
>>>
>>> I will appreciate any help or pointers to documentation on how to do this
>>>
>>> Thanks,
>>> Chenzo
>>>
>