This content has been marked as final.
Show 4 replies
-
1. Re: using suggestionBox with live data
nbelaevski Jun 12, 2009 1:48 PM (in response to asookazian)Hi,
StatelessSession has some significant disadvantages, so why not create DTO objects serving for displaying purposes only and do it just from the query? http://docs.jboss.org/hibernate/stable/core/reference/en/html/queryhql-select.html - it should be possible to do something like this:select new FamilyDTO(mother, mate, offspr) from DomesticCat as mother join mother.mate as mate left join mother.kittens as offspr
where FamilyDTO is not persistent entity, thus not being put into SMPC. -
2. Re: using suggestionBox with live data
asookazian Jun 12, 2009 2:27 PM (in response to asookazian)Thx for the fast response! I will try that out.
I checked out the booking app from Seam 2.1.2.GA and he's using this:
xhtml:<h:inputText id="searchString" value="#{hotelSearch.searchString}" style="width: 165px;"> <a:support id="onkeyup" event="onkeyup" actionListener="#{hotelSearch.find}" reRender="searchResults" /> </h:inputText>
backing bean:public void find() { page = 0; queryHotels(); } private void queryHotels() { List<Hotel> results = em.createQuery("select h from Hotel h where lower(h.name) like #{pattern} or lower(h.city) like #{pattern} or lower(h.zip) like #{pattern} or lower(h.address) like #{pattern}") .setMaxResults(pageSize+1) .setFirstResult(page * pageSize) .getResultList(); nextPageAvailable = results.size() > pageSize; if (nextPageAvailable) { hotels = new ArrayList<Hotel>(results.subList(0,pageSize)); } else { hotels = results; } }
This is not a suggestionBox component but it's similar in terms of onkeyup event listener. He's doing a dynamic query for each onkeyup event! Maybe if you know the resultset is small that's ok but perhaps this is not the best example. (Also, they're still not using SMPC in this booking example!)
Right now we have 300 rows in that table. Not sure how big it will grow. Thx again. -
3. Re: using suggestionBox with live data
asookazian Jun 12, 2009 11:10 PM (in response to asookazian)On pg. 538 of JPA w/ Hibernate book, I read the following:
If you have to create a few hundred or thousand objects in a unit of work, you may run into memory exhaustion. Every object that is passed to insert() or persist() is added to the persistence context cache. A straightforward solution is to flush and clear the persistence context after a certain number of objects.
So perhaps in my code I can simply writeem.clear();
after allRecoveredEquipmentManagementList has been populated by the JPQL createQuery() call.
I'm not sure the DTO approach will work b/c I need entities in the List so the <s:convertEntity> tag will work. -
4. Re: using suggestionBox with live data
mongkeh Aug 19, 2009 3:49 AM (in response to asookazian)Hi,
Can you post your SFSB Seam component Class?
Thanks.