tlaukkan / vaadin-lazyquerycontainer Goto Github PK
View Code? Open in Web Editor NEWLazy Query Container is a lazy loading container implementation for accessing data from business services.
Home Page: http://vaadin.com/directory#addon/117
Lazy Query Container is a lazy loading container implementation for accessing data from business services.
Home Page: http://vaadin.com/directory#addon/117
I know this bug is described also in issue #27 and fixed in lqc-version 2+. Unfortunately we can not use this versions because we can not update to vaadin 7. Is there a way to provide the bugfix also for version 1.2+ ?
Hello, when
exampleTable.addItem();
thorws IndexOutOfBoundsException
Caused by: java.lang.IndexOutOfBoundsException: Container size: 3 and item index requested: 3
at org.vaadin.addons.lazyquerycontainer.LazyQueryView.getItem(LazyQueryView.java:258)
at org.vaadin.addons.lazyquerycontainer.LazyQueryContainer.getItem(LazyQueryContainer.java:205)
at com.vaadin.ui.AbstractSelect.getItem(AbstractSelect.java:718)
at org.vaadin.addons.lazyquerycontainer.QueryItemStatusColumnGenerator.generateCell(QueryItemStatusColumnGenerator.java:75)
at org.vaadin.addons.lazyquerycontainer.QueryItemStatusColumnGenerator.generateCell(QueryItemStatusColumnGenerator.java:34)
at com.vaadin.ui.Table.parseItemIdToCells(Table.java:2286)
at com.vaadin.ui.Table.getVisibleCellsNoCache(Table.java:2147)
at com.vaadin.ui.Table.refreshRenderedCells(Table.java:1668)
The dependency to Java Persistence API should have a scope of 'provided' because it's provided by the runtime in Java EE applications.
<groupId>org.eclipse.persistence</groupId>
<artifactId>javax.persistence</artifactId>
<version>2.0.0</version>
<scope>provided</scope>
Right now you need to do this to get a bean:
((CompositeItem) usersTable.getItem(usersTable.getValue())).getItem("bean")).getBean()
Which does not seem very implementation-independant.
I noticed a NullPointerException which results from a corrupted cache.
I identified two causes for this:
-When trimmung the cache and modified or removed items are moved to the end of the itemCacheAccessLog, not the first entry is removed, but a random entry at position firstIndex
-When adding an item to the cache that is already contained, the old itemIndex is not removed from the itemCacheAccessLog. When later trimming the cache, at the second occurence of itemIndex the corresponding item cannot be found.
This patch should resolve the issues:
https://gist.github.com/721663
Hello, Tommi.
I have an issue with LazyQueryView when i use LazyQueryContainer.
I use com.vaadin.ui.Table class, When i scroll my table to the (for example) 3rd page (pageLength is 25) and then execute table.refreshRowCache() (for example user want to refresh the table and there may be some changes in DB since the last fetch) Vaadin's table is trying to load records 0-65 and it calls Container.getItemIds(int startIndex, int numberOfItems).
But unfortunatelly LazyQueryContainer loads these records with paging and performs 3 queries to DB which causes to load the table very slowly (my table contains over 10 000 000 records). I think it would be great if it loads all rows together and execute the query just one time.
Thank you for your job, it is very useful for me.
Best Regards, Alex.
For example, EntiyContainer, EntityQuery, EntityQueryDefinition, EntityQueryFactory, LazyQueryView, BeanQueryFactory, CompositeItem...
Why? This just makes this add-on harder to use.
A class that implements Serializable must :
private QueryView view;
Please, at least provide a protected getter and setter for this field so that extending the container will be more simple.
Hi,
I need to extend both mentioned classes to support further property mapping like drilldown into a map to pick up a specific value and so on. Therefore I would like to extends those classes which are declared as final. Is there a specific reason for this? If not, can you please remove this restriction?
Thanks! Sigurd
If an exception is thrown in BeanQuery constructor, cause is hidden because of way how exceptions are handled in BeanQueryFactory.constructQuery at line 83. 'throw new RuntimeException("Error instantiating query.")' should be replaced by 'throw new RuntimeException("Error instantiating query.", e)'.
Hi,
I've attached an ItemSetChangeListener to the container (LazyQueryContainer version 2.0.8) but this event is not fired when a filter is added/removed, even if adding/removing the filter actually changes the item set.
Thanks in advance,
Stefano
I am looking for the sources for version 1.2.8 (as published in the Vaadin Add-ons directory).
There does not seem to be a download, and the last tag made appears to be 1.2.7. I built a wrapper for your container and am investigating what appears to be a very subtle bug (though it could still be on my side).
Or Filter with only one argument
Could you implement the Container.Hierarchical interface to use the LazyQueryContainer with a TreeTable.
I need to overide method org.vaadin.addons.lazyquerycontainer.LazyQueryView.getQuery(). Maybe it should be protected.
Another thing is that when you need query object you always call getQuery() method except one time in method org.vaadin.addons.lazyquerycontainer.LazyQueryView.queryItem(int) (line: 255). Maybe it should call getQuery() too.
I understand the comments made on this issue, but the LazyQueryView has so much good debugging and caching functionality, that it seems a waste to have to either copy and paste the code to make your own changes, or to have to loose all those features.
The simplest solution seems to be to remove the final modifier, but in light of the aforementioned issue's comment, at the least it seems there could be an AbstractQueryView that LazyQueryView can extend, and thus make the caching and debugging functionality available to anyone who wants to implement their own QueryView.
If you add a new element, then delete it, then commit, EntityQuery attempts to persist and then remove the same element. This is kindof silly and runs into problems in the detached case (my code is hacked to support detached instances).
Instead, it would be better to just omit "deleted new" items altogether and not attempt any JPA operations on them.
Right now, it is a TreeMap. This forces propertyId's to be Comparable. As far as I can see in the code, there is no need to have a TreeMap - the order within the map is not relevant anywhere.
Any predictions for support vaadin 7.1.0?
When using the LQC, every call to size() from wherever, results in a server side call. The size() call should be cached as much as possible
Hi,
I tried compiling vaadin-lazyquerycontainer-jpa-example from maven. The pom.xml did not compile. I added this repository and I got it to compile:
<repository>
<id>vaadin-addons</id>
<url>http://maven.vaadin.com/vaadin-addons</url>
</repository>
but this time, mvn jetty:run did not work. Do i need extra setting?
I am using vaadin LQC addon feature with editable rows in my application.
I need access to addedItems and modifiedItems for validation before saving inside save event handler. Right now, i can access them inside saveItems() method but not inside save event handler.
Let me know is there a way to access them inside save event handler method.
Thanks in advance.
Hi,
im getting the following exception.
Cannot serialize session attribute com.vaadin.terminal.gwt.server.WebApplicationContext for session c73092566274e0753f638c8e6edf
java.io.NotSerializableException: org.vaadin.addons.lazyquerycontainer.EntityQueryFactory
EntityQueryFactory has a serialVersionUID but does not implement Serializable.
This is a bug, isnt it?
When adding a filter to LazyQueryView the method LazyQueryView#refresh() should create a new query on demand, but it doesn't.
Was there a valid reason to make this class final?
In version 1.2.0 this does not happen; in version 1.2.2 it does.
Sorting nested properties does not work properly for me. I have a simple OneToOne relation. A person CAN have an account. When I click on the table icon of the account column the data will be sorted. When I scroll down I see the following stacktrace:
SEVERE: java.lang.RuntimeException: Unable to get item id for index: 0 from container using Container.Indexed#getIdByIndex() even though container.size() > endIndex. Returned item id was null. Check your container implementation!
at com.vaadin.data.ContainerHelpers.getItemIdsUsingGetIdByIndex(ContainerHelpers.java:90)
I think this problem occurs for that persons that have no account assigned.
I initialize the container as following:
LazyEntityContainer container = new LazyEntityContainer(manager, Person.class, 200, "id", false, true, true);
container.addContainerProperty("firstName", String.class, "", true, true);
container.addContainerProperty("account.loginName", String.class, "", true, true);
Hello!
For illustrate my purpose, go to the demo page of this excellent plugin: https://www.eelis.biz/vaadin-lazyquerycontainer/LazyQueryContainer/
How can I solve this?
EntityManager.remove() cannot be invoked on a detached instance, or you get this:
java.lang.IllegalArgumentException: Removing a detached instance Foobar#3 at org.hibernate.ejb.event.EJB3DeleteEventListener.performDetachedEntityDeletionCheck(EJB3DeleteEventListener.java:65) at org.hibernate.event.def.DefaultDeleteEventListener.onDelete(DefaultDeleteEventListener.java:107) at org.hibernate.event.def.DefaultDeleteEventListener.onDelete(DefaultDeleteEventListener.java:73) at org.hibernate.impl.SessionImpl.fireDelete(SessionImpl.java:956) at org.hibernate.impl.SessionImpl.delete(SessionImpl.java:934) at org.hibernate.ejb.AbstractEntityManagerImpl.remove(AbstractEntityManagerImpl.java:702) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.invoke(ExtendedEntityManagerCreator.java:365) at $Proxy1582.remove(Unknown Source) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:240) at $Proxy1583.remove(Unknown Source) at org.vaadin.addons.lazyquerycontainer.EntityQuery.saveItems(EntityQuery.java:156)
Patch to fix is attached.
QueryItemStatusColumnGenerator#generateCell currently has the return type Component. Since Vaadin 6.7 the method signature has changed to declare an Object as a return type (see http://dev.vaadin.com/ticket/5916 ). Simple replace Component with Object on line 61 to fix it.
Currently the item ids seem to be hard coded into the container, meaning that for example, firstItemId() always returns "0" and getIdByIndex always returns an integer value which is equal to the index given as parameter.
This is really problematic, since each item id should uniquely identify a specific item. The container implements the Sortable interface, so after sorting the container, the first item may not be the same as it was in the unsorted container, but yet the firstItemId() method returns "0".
This wouldn't be a problem if each item would always have the exact same position in the container, but with the Sortable interface implemented, this is not the case. Same problem applies, if I want to extend the LQC and implement the Filterable interface.
Hello,
My issue concerns the class LazyQueryVIew and propertyItemMapCache field.
The field "propertyItemMapCache" inside LazyQueryView class is declared as java.util.Map and initialized with type java.util.HashMap. The problem is that there is no simple and good solution to assign any other type (e.g. org.apache.commons.collections.map.IdentityMap) to this field. This is a really serious problem if someone uses Property class which has its own implementation of hashCode/equals. I had to face this problem because my Property class (which implements vaadin Property) must implement its own equals method and it simply doesn't work with you hashmap. Why doesn't it work? Because cache map needs to keep the references to properties for each cell. And it should keep two different references to properties even if these two properties are equal, because they may lead to different Items, for example in my world two properties are equal if they are in the same column and have the same value (e.g. column "name" in database, and properties "John" and "John" from two different rows (Items)). In such case your map replaces the Item if equal property was inside hashmap before.. and when I need to get the Item for some property I get incorrect Item (for other but equal property). So, there is a real need to have the possibility to customize your map in order to work with custom Property classes.
The simplest solution is to privide a setter for this map (something like setPropertyItemMapCache(Map<Property, Item> map)) and now i could set my own map after constructing LazyQueryView object. By the way... why LazyQueryView is final? It breaks the open-closed principle.
Finally, the only workaround now is to set the map using reflection, which is not a good practice, but it works perfectly for me when I set it to "org.apache.commons.collections.map.IdentityMap". But I'm quite annoyed doing such tricks. I think this could be done in a simpler and better way, so I would really appreciate if you fix this bug in the closest future.
When the LazyQueryView cache size is exceeded modified and deleted items are not discarded; however if a page containing modified or deleted is reloaded those items are overwritten by the newly loaded items.
I made a simple change to LazyQueryView.java that seems to solve the issue:
299c299,304
// Update the item only if it's not modified or removed Item oldItem = itemCache.get(itemIndex); if (!modifiedItems.contains(oldItem) && !removedItems.contains(oldItem)) { itemCache.put(itemIndex, item); }
When getItemIds() is called, an array list with all item ids is generated.
Since the list consists of all integers from 0 to size-1, requested item ids can be generated on demand by a custom List.
See https://gist.github.com/721672 fo an implementation.
Hi,
is there a chance to make LazyIdList serializable?
I'd monkey patch it but as LazyQueryView is final, i cannot return my own serializable Id list.
This is a problem for container that have idPropertyId set. They are not serializable then and session restoration fails.
Thanks in advance,
Michael.
Hello,
I follow the Custom Query and QueueFactory example on the wiki page, ie Query loadItems return a list of BeanItems with my JPA object wrap inside BeanItem. The id on my JPA object is Long, not an integer.
Somehow with the lazy query container, it seems it use something like a natural number with an Integer as itemid to compare with the id from my JPA object which is a long.
I try to use this lazy query container onto a combo box like a Car object has one Driver (there could be a thousand of drivers to choose from). When the Car is in edit mode, try to select a driver from a list drivers return from lazy querycontainer and end up wtih
java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.Integer
at org.vaadin.addons.lazyquerycontainer.LazyQueryContainer.getItem(LazyQueryContainer.java:176)
at org.vaadin.addon.customfield.beanfield.BeanFieldPropertyConverter.parse(BeanFieldPropertyConverter.java:60)
at org.vaadin.addon.customfield.ConvertingValidator.validate(ConvertingValidator.java:29)
at com.vaadin.ui.AbstractField.validate(AbstractField.java:775)
at com.vaadin.ui.AbstractField.getErrorMessage(AbstractField.java:859)
at com.vaadin.ui.AbstractComponent.paint(AbstractComponent.java:783)
at com.vaadin.ui.AbstractOrderedLayout.paintContent(AbstractOrderedLayout.java:171)
at com.vaadin.ui.AbstractComponent.paint(AbstractComponent.java:781)
at com.vaadin.ui.AbstractOrderedLayout.paintContent(AbstractOrderedLayout.java:171)
at com.vaadin.ui.AbstractComponent.paint(AbstractComponent.java:781)
at com.vaadin.ui.Panel.paintContent(Panel.java:269)
at com.vaadin.ui.AbstractComponent.paint(AbstractComponent.java:781)
Have I chose a wrong example to follow, ie, I shouldn't follow Custom Query pattern / example?
AbstractBeanQuery doesn't implement Serializable, but does have a no-arg constructor. So upon deserializing a derived class that does implement Serializable, it will restore the fields of the derived class, and call the no-arg constructor of AbstractBeanQuery.
This results in the fields of the AbstractBeanQuery being left as null, later causing various NullPointerExceptions.
We can set the page size and lazyquerycontainer seems to automatically figure out how many table rows to fetch above and below the visible set of rows. It seems that the amount of rows that is are fetched is somewhat related to the height of each table row.
Is there a way to control this fetching behavior? if not it would be nice to be able to.
DefaultQueryDefinition & BeanQueryFactory are not serializable, which is an issue when you want to add Serialization support to one's application which uses the add-on.
I need to add a NestedProperty in a BeanItem.
But the Method AbstractBeanQuery.toItem(T) is private, thus for workaraound I copied the whole class and modified toItem(T) in the copied class.
A solution for me could be to have a protected method for creation of the BeanItem, which I could override:
private Item toItem(final T bean) {
BeanItem beanItem = createBeanItem(bean);
...
}
protected BeanItem createBeanItem(T bean) {
return new BeanItem(bean);
}
When I have a table that shows some images via Embedded, due to the prefetching of images that are not visibile into the browser I often run into performance/usability issues since the browser is trying to load images that aren't visible. This is especially issue in slower browsers like ff4 which already have rendering full screen vaadin tables.
Lazyquerycontainer should try to optimize such that images that aren't visible aren't loaded until they become visible. This kind of technique is for example used in iOS devices and other webapps.
See this forum post for a question about incorrect use of persist()
instead of merge()
.
In fact, now I'm getting this exception:
Caused by: javax.persistence.PersistenceException: org.hibernate.PersistentObjectException: detached entity passed to persist: Foobar at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1214) at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1147) at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1153) at org.hibernate.ejb.AbstractEntityManagerImpl.persist(AbstractEntityManagerImpl.java:678) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.invoke(ExtendedEntityManagerCreator.java:365) at $Proxy718.persist(Unknown Source) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:240) at $Proxy719.persist(Unknown Source) at org.vaadin.addons.lazyquerycontainer.EntityQuery.saveItems(EntityQuery.java:153) at org.vaadin.addons.lazyquerycontainer.LazyQueryView.commit(LazyQueryView.java:410) at org.vaadin.addons.lazyquerycontainer.LazyQueryContainer.commit(LazyQueryContainer.java:474) .... Caused by: org.hibernate.PersistentObjectException: detached entity passed to persist: Foobar at org.hibernate.event.def.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:127) at org.hibernate.event.def.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:61) at org.hibernate.impl.SessionImpl.firePersist(SessionImpl.java:808) at org.hibernate.impl.SessionImpl.persist(SessionImpl.java:782) at org.hibernate.impl.SessionImpl.persist(SessionImpl.java:786) at org.hibernate.ejb.AbstractEntityManagerImpl.persist(AbstractEntityManagerImpl.java:672)
Object itemId = sampleTable.addItem();
LazyQueryContainer.class
public final Object addItem() {
final int itemIndex = queryView.addItem();
final Object itemId = queryView.getItemIdList().get(itemIndex); <--??
notifyItemSetChanged();
return itemId;
}
LazyIdList.class
public T get(final int index) {
if (index < 0 || index >= lazyQueryView.size()) {
throw new IndexOutOfBoundsException();
}
final T itemId = (T) lazyQueryView.getItem(index).getItemProperty(idPropertyId).getValue();
idIndexMap.put(itemId, index);
return itemId;
}
public Item getItem(final int index) {
if (index < 0 || index >= size()) {
throw new IndexOutOfBoundsException("Container size: " + size() + " and item index requested: " + index); <-- THROWS
}
final int addedItemCount = addedItems.size();
if (index < addedItemCount) {
// an item from the addedItems was requested
return addedItems.get(index);
}
if (!itemCache.containsKey(index - addedItemCount)) {
// item is not in our cache, ask the query for more items
queryItem(index - addedItemCount);
} else {
// item is already in our cache
// refresh cache access log.
itemCacheAccessLog.remove(new Integer(index));
itemCacheAccessLog.addLast(new Integer(index));
}
return itemCache.get(index - addedItemCount);
}
Caused by: com.vaadin.ui.Table$CacheUpdateException: Error during Table cache update. Additional causes not shown.
at com.vaadin.ui.Table.maybeThrowCacheUpdateExceptions(Table.java:1690)
at com.vaadin.ui.Table.refreshRenderedCells(Table.java:1679)
at com.vaadin.ui.Table.refreshRowCache(Table.java:2613)
at com.vaadin.ui.Table.containerItemSetChange(Table.java:4401)
at org.vaadin.addons.lazyquerycontainer.LazyQueryContainer.notifyItemSetChanged(LazyQueryContainer.java:429)
at org.vaadin.addons.lazyquerycontainer.LazyQueryContainer.addItem(LazyQueryContainer.java:362)
at com.vaadin.ui.AbstractSelect.addItem(AbstractSelect.java:848)
at com.edicom.broker.services.manager.ui.panels.user.ApplicationsPanel$4.onDialogResult(ApplicationsPanel.java:373)
at com.edicom.broker.services.manager.ui.forms.NameDescriptionDialog.buttonClick(NameDescriptionDialog.java:124)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:508)
... 65 more
Caused by: java.lang.IndexOutOfBoundsException: Container size: 19 and item index requested: 19
at org.vaadin.addons.lazyquerycontainer.LazyQueryView.getItem(LazyQueryView.java:258)
at org.vaadin.addons.lazyquerycontainer.LazyQueryContainer.getItem(LazyQueryContainer.java:205)
at org.vaadin.addons.lazyquerycontainer.LazyQueryContainer.getContainerProperty(LazyQueryContainer.java:217)
at com.vaadin.ui.AbstractSelect.getContainerProperty(AbstractSelect.java:788)
at com.vaadin.ui.Table.parseItemIdToCells(Table.java:2248)
at com.vaadin.ui.Table.getVisibleCellsNoCache(Table.java:2147)
at com.vaadin.ui.Table.refreshRenderedCells(Table.java:1668)
Hi Tommy !
I just had some issue with LazyQueryContainer :
==> if I look into my table, the value (meaning the selected id : index of the deleted bean) is still there ! This causes side effects (such as NPE) because this item is not in the container anymore.
I tried to understand the value change listener mecanism while debugging but this is quite complex to me...all I can see is that some code in AbstractSelect should do the trick (fireItemSetChange() method) but it is not executed because of itemSetEventListeners being null, caused by the addListener(Container.ItemSetChangeListener listener) method being overriden in the container.
/**
* Fires the item set change event.
*/
protected void fireItemSetChange() {
if (itemSetEventListeners != null && !itemSetEventListeners.isEmpty()) {
final Container.ItemSetChangeEvent event = new ItemSetChangeEvent();
final Object[] listeners = itemSetEventListeners.toArray();
for (int i = 0; i < listeners.length; i++) {
((Container.ItemSetChangeListener) listeners[i])
.containerItemSetChange(event);
}
}
requestRepaint();
}
Anyway maybe my analysis sucks but can you tell me if it is normal behavior or a bug ?
Thanks ;)
Situation: Table is backed by LazyQueryContainer. Table has an ItemClickEvent.ItemClickListener defined. Container is changed(refreshed) and is in process of reloading. Table is clicked, this calls LazyQueryContainer.getItem passing 'null' as the itemId.
QueryView interface defines getItem as taking an int (not Integer) parameter.
This causes a NullPointerException since while null is a valid Integer, it's not a valid int.
Proposed code fix:
public final Item getItem(final Object itemId) {
return itemId == null ? null : queryView.getItem((Integer) itemId);
}
Hi tlaukkan !
Theres an problem in parsing "Or" Filters on version 2.0.4
When you add only two propertyes on filter, like
"addContainerFilter(new Or(...,...))", occours a IndexOfBoundsException.
Looking at your souce, i found the problem:
Line 277 of org.vaadin.addons.lazyquerycontainer.EntityQuery
"
Predicate predicate = cb.or(setFilter(filters.remove(0), cb, cq, root),
setFilter(filters.remove(1), cb, cq, root));
"
Needs to be changed to:
"
Predicate predicate = cb.or(setFilter(filters.remove(0), cb, cq, root),
setFilter(filters.remove(0), cb, cq, root));
"
Thanks by atention!
The following diff is a defensive programming against situations where a custom view cannot always accurately compute a size and can sometime overshoot.
It is a simple one-word fix. Someone else already suggested the same change in the Vaadin forums. Simply use the number of items actually returned instead of the expected count.
defensive programming if a view miscomputes the size
vaadin-lazyquerycontainer/src/main/java/org/vaadin/addons/lazyquerycontainer/LazyQueryView.java
diff --git a/vaadin-lazyquerycontainer/src/main/java/org/vaadin/addons/lazyquerycontainer/LazyQueryView.java b/vaadin-lazyquerycontainer/src/main/java/org/vaadin/addons/lazyquerycontainer/LazyQueryView.java
index 227d0fc..9cd372f 100644
--- a/vaadin-lazyquerycontainer/src/main/java/org/vaadin/addons/lazyquerycontainer/LazyQueryView.java
+++ b/vaadin-lazyquerycontainer/src/main/java/org/vaadin/addons/lazyquerycontainer/LazyQueryView.java
@@ -233,7 +233,7 @@
List items = getQuery().loadItems(startIndex, count);
long queryEndTime = System.currentTimeMillis();
for (int i = 0; i < count; i++) {
for (int i = 0; i < items.size(); i++) {
int itemIndex = startIndex + i;
Item item = items.get(i);
The size() method in the JPAQuery class expects the count function in the SQL to return a Long. On GAE with datanucleous an Integer is returned, so the cats fails. I propose to change the cast to Number, which should work in all cases.
Caused by: java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Long
at org.vaadin.addons.lazyquerycontainer.JpaQuery.size(JpaQuery.java:121)
at org.vaadin.addons.lazyquerycontainer.LazyQueryView.size(LazyQueryView.java:129)
at org.vaadin.addons.lazyquerycontainer.LazyQueryContainer.size(LazyQueryContainer.java:114)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.