How do I binding JPAContainer to TreeTable

Hi Everybody,

I am trying to bind a JPAContainer to a TreeTable. But I have trouble realizing it. Maybe someone can help me out.

I have a Person entity and a Department entity. Whereas a person belongs to a department and a department can have many or non persons. Like in the addressbook example for JPAContainer

When I use a JPAContainer<Person.class>…

JPAContainer<Person> persons = JPAContainerFactory.make(Person.class, Globals.getPersistenceUnitName());
TreeTable treeTable = new TreeTable();

… I get a NullPointerException:

Mrz 24, 2014 9:15:20 PM com.vaadin.server.DefaultErrorHandler doDefault
    at com.vaadin.addon.jpacontainer.JPAContainer.getParent(
    at com.vaadin.addon.jpacontainer.JPAContainer.isRoot(
    at com.vaadin.ui.TreeTable$AbstractStrategy.getDepth(
    at com.vaadin.ui.TreeTable.paintRowAttributes(
    at com.vaadin.ui.Table.paintRowAttributes(
    at com.vaadin.ui.Table.paintRow(
    at com.vaadin.ui.Table.paintRows(
    at com.vaadin.ui.Table.doPaintContent(
    at com.vaadin.ui.Table.paintContent(
    at com.vaadin.ui.TreeTable.paintContent(
    at com.vaadin.server.LegacyPaint.paint(
    at com.vaadin.server.communication.LegacyUidlWrite

Whereas when I use a JPAContainer<Department.class>…

        JPAContainer<Department> departments = JPAContainerFactory.make(Department.class, Globals.getPersistenceUnitName());
        TreeTable treeTable = new TreeTable();

… I get a

java.lang.IllegalArgumentException: Invalid property name

How do I do it the proper way? I want to display the departments (hierarchically) and the people working in it. Any help is appreciated.

Thanks in advance.

My Person entity:

public class Person implements Serializable {
    @GeneratedValue(strategy = GenerationType.AUTO)
    private int id;
    private String name;
    private Department department;
    public Person() {

... getter and setters

My Department entity:

public class Department implements Serializable {

    @GeneratedValue(strategy = GenerationType.AUTO)
    private int id;

    private String name;

    @OneToMany(mappedBy = "department")
    private Set<Person> persons;

    private Boolean superDepartment;

    private Department parent;
    private String hierarchicalName;

    public Department() {

    .... getter and setters

    public boolean isSuperDepartment() {
        if (superDepartment == null) {
            superDepartment = getPersons().isEmpty();
        return superDepartment;

    public String getHierarchicalName() {
        if (parent != null) {
            return parent.toString() + " : " + name;
        return name;

    public String toString() {
        return getHierarchicalName();


Did you find a solution for this problem?


I wish he answered you as i’m curiously sitting with the exact same situation at the moment