RequestFactory findXXX method cause performance pitfall

89 views
Skip to first unread message

Lopakhin

unread,
Mar 12, 2012, 12:39:00 AM3/12/12
to google-we...@googlegroups.com
In a common scenario of Web application, we usually populate cellTable,cellList with our data from RequestFactory context's method, such as findAll(), at this point , we already done  the database query that get all entity ,but RequestFactory dictate that , to prepare with appropriate manipulating methods , RF has to go over the list again one by one ,resulting in additional n queries whose result set already in the memory.As I monitored in the console, the overhead is substantial, even with JPA batching present, the performance is still crippled.

According to this post in stackoverflow , we surely can override ServiceDecorator,but it seems that we lose the control over what we can do with this entity.

By far I can not think better solution for this, may be go back to GWT RPC is good idea.

Thomas Broyer

unread,
Mar 12, 2012, 4:36:30 AM3/12/12
to google-we...@googlegroups.com
You can use a Locator and override its isLive() method (whose default implementation calls getId() and then find())

(IMO, you *should* use a Locator rather than this static-methods anti-pattern anyway)

Jesse Hutton

unread,
Mar 12, 2012, 10:07:31 AM3/12/12
to google-we...@googlegroups.com

Another way to mitigate this problem is to always use
EntityManager#find() in your Locator since that will return the entity
from the current persistence context without hitting the db if it is
already there.

Jesse

Message has been deleted

Lopakhin

unread,
Mar 13, 2012, 1:57:39 AM3/13/12
to google-we...@googlegroups.com
Both solutions are great, and I re-read RF official documentation ,it actually uses Jesse's solution which I did't get it in the first place.
Reply all
Reply to author
Forward
0 new messages