Fabii
Fabii

Reputation: 3890

Ids must exist in the Container or as a generated column, missing id: id

Any idea of why I'm getting this error, I've tried all naming convention (lowercase / uppercase)

I am using Vaadin, here is a snippet of my code:

    public class Usercontainer extends BeanItemContainer<Users> implements Serializable{
    public static final Object[] NATURAL_COL_ORDER = new Object[] {"id", "empCode"};

    public static final String[] COL_HEADERS_ENGLISH = new String[] {"User Id", "Emp code"};

    public Usercontainer() throws IllegalArgumentException {
        super(Users.class);
    }

    public static Usercontainer createTestData(){
        Usercontainer users = null;     
        try
        {
            users = new Usercontainer();
            for(int i=0; i<10;i++){
                Users user = new Users();
                user.setId(i*10);
                user.setEmpcode("C00"+i);
                users.addItem(user);
            }
        }
        catch(Exception e){System.out.println("Error :"+e.getMessage());}       
        return users;       
    }
}

@Entity
@Table(name="_user")
public class Users {
    //private String name;
    public int id;
    public String empcode;

        @Id
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }


    public String getEmpcode() {
        return empcode;
    }
    public void setEmpcode(String empcode) {
        this.empcode = empcode;
    }


}

    public class UserTable extends Table {


    public UserTable(App1Application app){
        setSizeFull();
        setContainerDataSource(app.getDataSource());
        setVisibleColumns(Usercontainer.NATURAL_COL_ORDER);
        setColumnHeaders(Usercontainer.COL_HEADERS_ENGLISH);
        this.setColumnReorderingAllowed(true);
        setSelectable(true);
        setImmediate(true);
        addListener((Property.ValueChangeListener)app);
        setNullSelectionAllowed(false);


    }
}

Upvotes: 1

Views: 3803

Answers (1)

kszk
kszk

Reputation: 102

If you use the "empCode" in the NATURAL_COL_ORDER then you should use the getEmpCode() getter method in the entity class (instead of getEmpcode() ) imho.

Upvotes: 2

Related Questions