-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi
I'm using frameworks combination as described in topic.
I my project I want ZK to be talking with Spring's beans and Spring via JPA to be talking with JPA implementation - Hibernate. Everything works fine, but I have very large collection to retrieve from DB. I was thinking about some kind of lazy data loading (well, not strict definition of lazy loading or fetching, but I wanted to retrieve lazily data collection from JPA).
Here is an example:
Suppose we have listbox with paging (pageSize=10). Data is retrieved from Spring’s bean by spring variable resolver. Spring requests objects from Hibernate through JPA, suppose it is a named query, selecting all entries from table.
OK, everything works fine, I have data, paging works....but I'd like to retrieve only 10 results at once. This means that when I change page in my list box, another query to DB would be performed.
Is it possible to do this automatically? With some kind of lazy loading mechanism?
I couldn't find solution anywhere (perhaps I've been searching with wrong keywords)
Do you have any ideas how to accomplish this task?
I know of no way to do it automatically. I think you're going to have to hook the onPage event of the pager and do it yourself. I create service and DAO methods that include a beginning row # and size in case I need to do this kind of thing.
Hi caclark,
Yes your solution sounds cool, however I was thinking about resolving this issue on entity layer.
For example create one entity with index field and reference to "real" entity (mapped one to one). From the DB point of view there would be one additional table:
TABLE:REAL_ENTITY_POINTER
ID: int (PK)
POINTER_TO_ANOTHER_TABLE_WITH_REAL_DATA: int (FK)
This approach + JPA lazy fetching could do the trick, because Hibernate would download data only, when needed.
I hope there is smarter solution, without making entity layer too complicated and without writing a lot of code.
To complete this thread:
There some reference how to handle this request:
1.) Smalltalk about Handling huge data using ZK
This example handles the paging event itself (like Cary's approach).
+ Grow/List is always small and contains only one page of data
- you need extra code to manage the paging -events
2.) Use own Listmodels like the zksample2 project (by terrytornado and bbruhns)
Here is the utilclass PagedBindingListWrapper
And here is the use of this class: ArticleListCtrl
+ extra coding is reduced to the minium
- most zk versions create dummy objects for all objects
i.e. the data contains i.e. 1 Mio row, ZK prepare 1 Mio (listbox/grid) empty entries [1]
(-) some people would prefer JPA objects instead of hibernate
[1] The enterprise edition (ZK 5) should be smarter (not tested, i've only read the changes) and creates only required list/rowitems
However, is should be possisble to handle this request with common util classes.
/Robert
Asked: 2010-09-17 07:24:27 +0800
Seen: 827 times
Last updated: Sep 21 '10