Table - JPAContainer oneToMany NestedProperties

Hi all,

i have this manytomany database relation with product_has_category table:

product ----|< product_has_category |>— category

Java Entities seems to be ok as i tested them. But when i try this:

            ...

            JPAContainer<Product> products = JPAContainerFactory.make(Product.class,"myorm.orm");
	Category c = new Category();
	c.setCategoryId(1);
	Equal eq = new Equal("productHasCategories.category",c);
	products.addContainerFilter(eq);
	products.addNestedContainerProperty("produtHasCategories.category.title");

            layout.addComponent(new Table("productTableTest",products));

            ....

addContainerFilter runs ok, but i tried to access to category properties and i obtain that :

java.lang.IllegalArgumentException: Invalid property name
com.vaadin.addon.jpacontainer.PropertyList.getNestedProperty(PropertyList.java:421)
com.vaadin.addon.jpacontainer.PropertyList.getNestedProperty(PropertyList.java:391)
com.vaadin.addon.jpacontainer.PropertyList.addNestedProperty(PropertyList.java:248)
com.vaadin.addon.jpacontainer.JPAContainer.addNestedContainerProperty(JPAContainer.java:291)
com.mycatalogbox.vaadin.MyCatalogBoxVaadinUI.init(MyCatalogBoxVaadinUI.java:90)
com.vaadin.ui.UI.doInit(UI.java:529)
com.vaadin.server.AbstractCommunicationManager.getBrowserDetailsUI(AbstractCommunicationManager.java:2468)
com.vaadin.server.AbstractCommunicationManager.handleBrowserDetailsRequest(AbstractCommunicationManager.java:2362)
com.vaadin.server.VaadinServlet.service(VaadinServlet.java:325)
com.vaadin.server.VaadinServlet.service(VaadinServlet.java:201)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)

i tried in different ways without success. It’s possible to access in a Vaadin Table with JPAContainer to oneToMany attributes ??

Thank you in advance,

JuanMa

Run into the same problem. Looks like JPAContainer doesn’t support @OneToMany relationship.

JPAContainer supports OneToMany annotations in simpler cases (like InvoiceItems of an Invoice in the
demo
), but if I remember correctly, not as intermediate levels of nested properties the way you are trying to use them. Each of the intermediate levels of the nested property must have a single value - only the last level can be have a collection as its value. The nested property string is not passed directly to JPA but is parsed to find type information about each level etc.

(I assume the typo “produtHasCategories” in the sample code is only in the forum post as it could affect the error you get.)