Hi
I cannot get the demo running on JBoss AS 7 with a simple entity. The demo is shown here: http://vaadin.com/directory/#addon/lazy-query-container → JPA Application Example
Im always getting a ClassCastException when I add the entityContainer to the table:
If I do not insert any data into the database the application starts without problems and shows an empty table.
my simple entity looks like this:
@javax.persistence.Entity
@javax.persistence.Table(name = “CostAmount”)
public class CostAmount implements Serializable {
private static final long serialVersionUID = 1L;
@javax.persistence.Id
@javax.persistence.GeneratedValue
private long id;
private String amount;
public long getId() {
return id;
}
public void setId(final long id) {
this.id = id;
}
public String getAmount() {
return amount;
}
public void setAmount(final String amount) {
this.amount = amount;
}
@Override
public String toString() {
return toString(false);
}
public String toString(boolean idOnly) {
if (idOnly) {
return String.valueOf(getId());
} else {
StringBuffer sb = new StringBuffer();
sb.append("realtf.data.CostAmount[ ");
sb.append("Id=").append(getId()).append(" ");
// sb.append("Version=").append(getVersion()).append(" ");
sb.append("Amount=").append(getAmount()).append(" ");
// sb.append("Type=").append(getType()).append(" ");
sb.append("]");
return sb.toString();
}
}
}
And the entityContainer setup goes as follows:
entityContainer = new EntityContainer(entityManager, true, false, true, CostAmount.class, 100,
new Object { “amount” }, new boolean
{ true });
entityContainer.addContainerProperty(LazyQueryView.PROPERTY_ID_ITEM_STATUS, QueryItemStatus.class,
QueryItemStatus.None, true, false);
// entityContainer.addContainerProperty(“id”, Long.class, null, true, true);
entityContainer.addContainerProperty(“amount”, String.class, “”, true, true);
entityContainer
.addContainerProperty(LazyQueryView.DEBUG_PROPERTY_ID_QUERY_INDEX, Integer.class, 0, true, false);
entityContainer
.addContainerProperty(LazyQueryView.DEBUG_PROPERTY_ID_BATCH_INDEX, Integer.class, 0, true, false);
entityContainer.addContainerProperty(LazyQueryView.DEBUG_PROPERTY_ID_BATCH_QUERY_TIME, Integer.class, 0, true,
false);
The line where it crashes:
table.setContainerDataSource(entityContainer);
with the exception:
java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.Integer
com.vaadin.data.util.converter.StringToIntegerConverter.convertToPresentation(StringToIntegerConverter.java:34)
com.vaadin.ui.Table.formatPropertyValue(Table.java:3782)
com.vaadin.ui.Table.getPropertyValue(Table.java:3724)
com.vaadin.ui.Table.parseItemIdToCells(Table.java:2105)
com.vaadin.ui.Table.getVisibleCellsNoCache(Table.java:1970)
com.vaadin.ui.Table.refreshRenderedCells(Table.java:1642)
com.vaadin.ui.Table.enableContentRefreshing(Table.java:2914)
com.vaadin.ui.Table.setContainerDataSource(Table.java:2494)
com.vaadin.ui.Table.setContainerDataSource(Table.java:2435)
com.example.mytry.MytryUI.init(MytryUI.java:167)
com.vaadin.ui.UI.doInit(UI.java:523)
com.vaadin.server.AbstractCommunicationManager.getBrowserDetailsUI(AbstractCommunicationManager.java:2448)
com.vaadin.server.AbstractCommunicationManager.handleBrowserDetailsRequest(AbstractCommunicationManager.java:2343)
com.vaadin.server.VaadinServlet.service(VaadinServlet.java:325)
com.vaadin.server.VaadinServlet.service(VaadinServlet.java:201)
javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
What is WRONG??? PLS HELP