tlaukkan/vaadin-lazyquerycontainer — Issue #26: LazyQueryContainer.getItem throw ClassCastException: java.lang.Long cannot be cast to java.lang.Integer
Author: vinny1976
Created: 2011-12-13 23:14:34+00:00
State: open

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?