EntityQuery implementation and documentation

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

EntityQuery implementation and documentation

Pierre Smits
Scott,

I noticed you recently started to change various areas of code from .find
(functionality) to the new entityquery implementation. As find operations
take place on various level throughout the entire set of functionalities in
OFBiz there is a lot to get converted. This not only applies to java code,
but also to groovy code and even to areas in simple services and screens
and forms. All in all a enormous endeavour for this community, let alone
for just one contributor.

Could you do a page in the technical wiki explaining how it all works and
provide some examples so that others can:

   - assist you in those areas
   - take proper notice of this new functionality when they are working on
   new applications and/or solutions.

With such a page not only we can try to speed up the transition, but we
also help to avoid regressions.

Regards,

Pierre Smits

*ORRTIZ.COM <http://www.orrtiz.com>*
Services & Solutions for Cloud-
Based Manufacturing, Professional
Services and Retail & Trade
http://www.orrtiz.com
Reply | Threaded
Open this post in threaded view
|

Re: EntityQuery implementation and documentation

Scott Gray-2
Hi Pierre,

If you review the code the implementation is actually quite straightforward and it simply provides a more user friendly API to functionality that already exists in the GenericDelegator and EntityUtil classes.

I documented the API as I wrote it and that can be accessed here: http://ci.apache.org/projects/ofbiz/site/javadocs/org/ofbiz/entity/util/EntityQuery.html

Examples are already in the code base after I spend many hours converting hundreds of classes to use the new API.

I have no desire to write an additional document but anyone who is willing is more than welcome to.

Regards
Scott

On 11/11/2014, at 6:49 am, Pierre Smits <[hidden email]> wrote:

> Scott,
>
> I noticed you recently started to change various areas of code from .find
> (functionality) to the new entityquery implementation. As find operations
> take place on various level throughout the entire set of functionalities in
> OFBiz there is a lot to get converted. This not only applies to java code,
> but also to groovy code and even to areas in simple services and screens
> and forms. All in all a enormous endeavour for this community, let alone
> for just one contributor.
>
> Could you do a page in the technical wiki explaining how it all works and
> provide some examples so that others can:
>
>   - assist you in those areas
>   - take proper notice of this new functionality when they are working on
>   new applications and/or solutions.
>
> With such a page not only we can try to speed up the transition, but we
> also help to avoid regressions.
>
> Regards,
>
> Pierre Smits
>
> *ORRTIZ.COM <http://www.orrtiz.com>*
> Services & Solutions for Cloud-
> Based Manufacturing, Professional
> Services and Retail & Trade
> http://www.orrtiz.com

Reply | Threaded
Open this post in threaded view
|

Re: EntityQuery implementation and documentation

Jacopo Cappellato-4
In reply to this post by Pierre Smits
I would like to add that today I have enhanced the DSL available in all Groovy scripts in OFBiz by adding support for the EntityUtil class.

From within a Groovy script you can now run queries in the following ways:

// select all fields from one order header record
orderHeader = from('OrderHeader').where('orderId', orderId).queryFirst()
// ... or the equivalent
orderHeader = select().from('OrderHeader').where('orderId', orderId).queryFirst()

// select only two fields from the order header record
orderHeader = select(‘orderId’, ‘orderDate’).from('OrderHeader').where('orderId', orderId).queryFirst()

The OrderView.groovy file has some examples of its usage.

I think this is a very user friendly way of running queries and I am sure users will like it.

Jacopo

On Nov 10, 2014, at 6:49 PM, Pierre Smits <[hidden email]> wrote:

> Scott,
>
> I noticed you recently started to change various areas of code from .find
> (functionality) to the new entityquery implementation. As find operations
> take place on various level throughout the entire set of functionalities in
> OFBiz there is a lot to get converted. This not only applies to java code,
> but also to groovy code and even to areas in simple services and screens
> and forms. All in all a enormous endeavour for this community, let alone
> for just one contributor.
>
> Could you do a page in the technical wiki explaining how it all works and
> provide some examples so that others can:
>
>   - assist you in those areas
>   - take proper notice of this new functionality when they are working on
>   new applications and/or solutions.
>
> With such a page not only we can try to speed up the transition, but we
> also help to avoid regressions.
>
> Regards,
>
> Pierre Smits
>
> *ORRTIZ.COM <http://www.orrtiz.com>*
> Services & Solutions for Cloud-
> Based Manufacturing, Professional
> Services and Retail & Trade
> http://www.orrtiz.com

Reply | Threaded
Open this post in threaded view
|

Re: EntityQuery implementation and documentation

Nicolas Malin-2
Le 11/11/2014 13:49, Jacopo Cappellato a écrit :
> I think this is a very user friendly way of running queries and I am sure users will like it.
Jacopo ... It's really a GROOVY feature :) ! I like it.

Nicolas
Reply | Threaded
Open this post in threaded view
|

Re: EntityQuery implementation and documentation

Pranay Pandey-2
In reply to this post by Jacopo Cappellato-4

Love it, thanks Jacopo :)

Thanks,

Pranay Pandey
Senior Manager, Enterprise Software Development
HotWax Media
http://www.hotwaxmedia.com
ApacheCon US 2014 Silver Sponsor
http://na.apachecon.com/sponsor/our-sponsors

On Nov 11, 2014, at 6:19 PM, Jacopo Cappellato <[hidden email]> wrote:

> I would like to add that today I have enhanced the DSL available in all Groovy scripts in OFBiz by adding support for the EntityUtil class.
>
> From within a Groovy script you can now run queries in the following ways:
>
> // select all fields from one order header record
> orderHeader = from('OrderHeader').where('orderId', orderId).queryFirst()
> // ... or the equivalent
> orderHeader = select().from('OrderHeader').where('orderId', orderId).queryFirst()
>
> // select only two fields from the order header record
> orderHeader = select(‘orderId’, ‘orderDate’).from('OrderHeader').where('orderId', orderId).queryFirst()
>
> The OrderView.groovy file has some examples of its usage.
>
> I think this is a very user friendly way of running queries and I am sure users will like it.
>
> Jacopo
>
> On Nov 10, 2014, at 6:49 PM, Pierre Smits <[hidden email]> wrote:
>
>> Scott,
>>
>> I noticed you recently started to change various areas of code from .find
>> (functionality) to the new entityquery implementation. As find operations
>> take place on various level throughout the entire set of functionalities in
>> OFBiz there is a lot to get converted. This not only applies to java code,
>> but also to groovy code and even to areas in simple services and screens
>> and forms. All in all a enormous endeavour for this community, let alone
>> for just one contributor.
>>
>> Could you do a page in the technical wiki explaining how it all works and
>> provide some examples so that others can:
>>
>>  - assist you in those areas
>>  - take proper notice of this new functionality when they are working on
>>  new applications and/or solutions.
>>
>> With such a page not only we can try to speed up the transition, but we
>> also help to avoid regressions.
>>
>> Regards,
>>
>> Pierre Smits
>>
>> *ORRTIZ.COM <http://www.orrtiz.com>*
>> Services & Solutions for Cloud-
>> Based Manufacturing, Professional
>> Services and Retail & Trade
>> http://www.orrtiz.com
>

Reply | Threaded
Open this post in threaded view
|

Re: EntityQuery implementation and documentation

Jacques Le Roux
Administrator
In reply to this post by Scott Gray-2
Hi Scott,

I have just a question.

The private "useCache" is false by default. So when we don't want to use the cache during a query we don't need to provide ".cache(false)" in the
chain, it's by default.
Then when is "cache(boolean useCache)" useful? Would not cache() be enough?

Jacques

Le 10/11/2014 21:06, Scott Gray a écrit :

> Hi Pierre,
>
> If you review the code the implementation is actually quite straightforward and it simply provides a more user friendly API to functionality that already exists in the GenericDelegator and EntityUtil classes.
>
> I documented the API as I wrote it and that can be accessed here: http://ci.apache.org/projects/ofbiz/site/javadocs/org/ofbiz/entity/util/EntityQuery.html
>
> Examples are already in the code base after I spend many hours converting hundreds of classes to use the new API.
>
> I have no desire to write an additional document but anyone who is willing is more than welcome to.
>
> Regards
> Scott
>
> On 11/11/2014, at 6:49 am, Pierre Smits <[hidden email]> wrote:
>
>> Scott,
>>
>> I noticed you recently started to change various areas of code from .find
>> (functionality) to the new entityquery implementation. As find operations
>> take place on various level throughout the entire set of functionalities in
>> OFBiz there is a lot to get converted. This not only applies to java code,
>> but also to groovy code and even to areas in simple services and screens
>> and forms. All in all a enormous endeavour for this community, let alone
>> for just one contributor.
>>
>> Could you do a page in the technical wiki explaining how it all works and
>> provide some examples so that others can:
>>
>>    - assist you in those areas
>>    - take proper notice of this new functionality when they are working on
>>    new applications and/or solutions.
>>
>> With such a page not only we can try to speed up the transition, but we
>> also help to avoid regressions.
>>
>> Regards,
>>
>> Pierre Smits
>>
>> *ORRTIZ.COM <http://www.orrtiz.com>*
>> Services & Solutions for Cloud-
>> Based Manufacturing, Professional
>> Services and Retail & Trade
>> http://www.orrtiz.com
>
>
Reply | Threaded
Open this post in threaded view
|

Re: EntityQuery implementation and documentation

Jacques Le Roux
Administrator
Finally another question: I wanted to ask if you have made a benchmark with load tests? I guess this new layer should have a minimal impact on
performance, but better to be safe than sorry.

Jacques

Le 28/11/2014 10:09, Jacques Le Roux a écrit :

> Hi Scott,
>
> I have just a question.
>
> The private "useCache" is false by default. So when we don't want to use the cache during a query we don't need to provide ".cache(false)" in the
> chain, it's by default.
> Then when is "cache(boolean useCache)" useful? Would not cache() be enough?
>
> Jacques
>
> Le 10/11/2014 21:06, Scott Gray a écrit :
>> Hi Pierre,
>>
>> If you review the code the implementation is actually quite straightforward and it simply provides a more user friendly API to functionality that
>> already exists in the GenericDelegator and EntityUtil classes.
>>
>> I documented the API as I wrote it and that can be accessed here:
>> http://ci.apache.org/projects/ofbiz/site/javadocs/org/ofbiz/entity/util/EntityQuery.html
>>
>> Examples are already in the code base after I spend many hours converting hundreds of classes to use the new API.
>>
>> I have no desire to write an additional document but anyone who is willing is more than welcome to.
>>
>> Regards
>> Scott
>>
>> On 11/11/2014, at 6:49 am, Pierre Smits <[hidden email]> wrote:
>>
>>> Scott,
>>>
>>> I noticed you recently started to change various areas of code from .find
>>> (functionality) to the new entityquery implementation. As find operations
>>> take place on various level throughout the entire set of functionalities in
>>> OFBiz there is a lot to get converted. This not only applies to java code,
>>> but also to groovy code and even to areas in simple services and screens
>>> and forms. All in all a enormous endeavour for this community, let alone
>>> for just one contributor.
>>>
>>> Could you do a page in the technical wiki explaining how it all works and
>>> provide some examples so that others can:
>>>
>>>    - assist you in those areas
>>>    - take proper notice of this new functionality when they are working on
>>>    new applications and/or solutions.
>>>
>>> With such a page not only we can try to speed up the transition, but we
>>> also help to avoid regressions.
>>>
>>> Regards,
>>>
>>> Pierre Smits
>>>
>>> *ORRTIZ.COM <http://www.orrtiz.com>*
>>> Services & Solutions for Cloud-
>>> Based Manufacturing, Professional
>>> Services and Retail & Trade
>>> http://www.orrtiz.com
>>
>>
>
Reply | Threaded
Open this post in threaded view
|

Re: EntityQuery implementation and documentation

Scott Gray-2
Hi Jacques,

Regarding question #1, pretty much every method in the API has been
added because I found a use case for it in the existing code.  In this
case, it's not at all uncommon for "useCache" parameter to be passed
into a method that performs the query.  If you look at the conversions
done so far you'll find a few such examples.  Here's an example use
case:
public static GenericValue getProduct(String productId, boolean useCache) {
  return EntityQuery.use(delegator).from("Product").where("productId",
productId).cache(useCache).queryOne();
}

For #2, I've haven't loaded tested the cost of creation of one
additional object for each query performed, it seemed inconsequential
to me compared to the value of a decent API.


Regards
Scott


On Fri, Nov 28, 2014 at 10:56 PM, Jacques Le Roux
<[hidden email]> wrote:

> Finally another question: I wanted to ask if you have made a benchmark with
> load tests? I guess this new layer should have a minimal impact on
> performance, but better to be safe than sorry.
>
> Jacques
>
> Le 28/11/2014 10:09, Jacques Le Roux a écrit :
>
>> Hi Scott,
>>
>> I have just a question.
>>
>> The private "useCache" is false by default. So when we don't want to use
>> the cache during a query we don't need to provide ".cache(false)" in the
>> chain, it's by default.
>> Then when is "cache(boolean useCache)" useful? Would not cache() be
>> enough?
>>
>> Jacques
>>
>> Le 10/11/2014 21:06, Scott Gray a écrit :
>>>
>>> Hi Pierre,
>>>
>>> If you review the code the implementation is actually quite
>>> straightforward and it simply provides a more user friendly API to
>>> functionality that already exists in the GenericDelegator and EntityUtil
>>> classes.
>>>
>>> I documented the API as I wrote it and that can be accessed here:
>>> http://ci.apache.org/projects/ofbiz/site/javadocs/org/ofbiz/entity/util/EntityQuery.html
>>>
>>> Examples are already in the code base after I spend many hours converting
>>> hundreds of classes to use the new API.
>>>
>>> I have no desire to write an additional document but anyone who is
>>> willing is more than welcome to.
>>>
>>> Regards
>>> Scott
>>>
>>> On 11/11/2014, at 6:49 am, Pierre Smits <[hidden email]> wrote:
>>>
>>>> Scott,
>>>>
>>>> I noticed you recently started to change various areas of code from
>>>> .find
>>>> (functionality) to the new entityquery implementation. As find
>>>> operations
>>>> take place on various level throughout the entire set of functionalities
>>>> in
>>>> OFBiz there is a lot to get converted. This not only applies to java
>>>> code,
>>>> but also to groovy code and even to areas in simple services and screens
>>>> and forms. All in all a enormous endeavour for this community, let alone
>>>> for just one contributor.
>>>>
>>>> Could you do a page in the technical wiki explaining how it all works
>>>> and
>>>> provide some examples so that others can:
>>>>
>>>>    - assist you in those areas
>>>>    - take proper notice of this new functionality when they are working
>>>> on
>>>>    new applications and/or solutions.
>>>>
>>>> With such a page not only we can try to speed up the transition, but we
>>>> also help to avoid regressions.
>>>>
>>>> Regards,
>>>>
>>>> Pierre Smits
>>>>
>>>> *ORRTIZ.COM <http://www.orrtiz.com>*
>>>> Services & Solutions for Cloud-
>>>> Based Manufacturing, Professional
>>>> Services and Retail & Trade
>>>> http://www.orrtiz.com
>>>
>>>
>>>
>>
>
Reply | Threaded
Open this post in threaded view
|

Re: EntityQuery implementation and documentation

Jacques Le Roux
Administrator
Hi Scott,

I agree it's a quite an improvement once you get used to it. Thanks for your idea and work on it!

Jacques

Le 28/11/2014 11:36, Scott Gray a écrit :

> Hi Jacques,
>
> Regarding question #1, pretty much every method in the API has been
> added because I found a use case for it in the existing code.  In this
> case, it's not at all uncommon for "useCache" parameter to be passed
> into a method that performs the query.  If you look at the conversions
> done so far you'll find a few such examples.  Here's an example use
> case:
> public static GenericValue getProduct(String productId, boolean useCache) {
>    return EntityQuery.use(delegator).from("Product").where("productId",
> productId).cache(useCache).queryOne();
> }
>
> For #2, I've haven't loaded tested the cost of creation of one
> additional object for each query performed, it seemed inconsequential
> to me compared to the value of a decent API.
>
>
> Regards
> Scott
>
>
> On Fri, Nov 28, 2014 at 10:56 PM, Jacques Le Roux
> <[hidden email]> wrote:
>> Finally another question: I wanted to ask if you have made a benchmark with
>> load tests? I guess this new layer should have a minimal impact on
>> performance, but better to be safe than sorry.
>>
>> Jacques
>>
>> Le 28/11/2014 10:09, Jacques Le Roux a écrit :
>>
>>> Hi Scott,
>>>
>>> I have just a question.
>>>
>>> The private "useCache" is false by default. So when we don't want to use
>>> the cache during a query we don't need to provide ".cache(false)" in the
>>> chain, it's by default.
>>> Then when is "cache(boolean useCache)" useful? Would not cache() be
>>> enough?
>>>
>>> Jacques
>>>
>>> Le 10/11/2014 21:06, Scott Gray a écrit :
>>>> Hi Pierre,
>>>>
>>>> If you review the code the implementation is actually quite
>>>> straightforward and it simply provides a more user friendly API to
>>>> functionality that already exists in the GenericDelegator and EntityUtil
>>>> classes.
>>>>
>>>> I documented the API as I wrote it and that can be accessed here:
>>>> http://ci.apache.org/projects/ofbiz/site/javadocs/org/ofbiz/entity/util/EntityQuery.html
>>>>
>>>> Examples are already in the code base after I spend many hours converting
>>>> hundreds of classes to use the new API.
>>>>
>>>> I have no desire to write an additional document but anyone who is
>>>> willing is more than welcome to.
>>>>
>>>> Regards
>>>> Scott
>>>>
>>>> On 11/11/2014, at 6:49 am, Pierre Smits <[hidden email]> wrote:
>>>>
>>>>> Scott,
>>>>>
>>>>> I noticed you recently started to change various areas of code from
>>>>> .find
>>>>> (functionality) to the new entityquery implementation. As find
>>>>> operations
>>>>> take place on various level throughout the entire set of functionalities
>>>>> in
>>>>> OFBiz there is a lot to get converted. This not only applies to java
>>>>> code,
>>>>> but also to groovy code and even to areas in simple services and screens
>>>>> and forms. All in all a enormous endeavour for this community, let alone
>>>>> for just one contributor.
>>>>>
>>>>> Could you do a page in the technical wiki explaining how it all works
>>>>> and
>>>>> provide some examples so that others can:
>>>>>
>>>>>     - assist you in those areas
>>>>>     - take proper notice of this new functionality when they are working
>>>>> on
>>>>>     new applications and/or solutions.
>>>>>
>>>>> With such a page not only we can try to speed up the transition, but we
>>>>> also help to avoid regressions.
>>>>>
>>>>> Regards,
>>>>>
>>>>> Pierre Smits
>>>>>
>>>>> *ORRTIZ.COM <http://www.orrtiz.com>*
>>>>> Services & Solutions for Cloud-
>>>>> Based Manufacturing, Professional
>>>>> Services and Retail & Trade
>>>>> http://www.orrtiz.com
>>>>
>>>>
>