Vaadin 找不到 BeanContainer 的 ID 属性

Vaadin can't find BeanContainer's Id Property

我试图在填充 BeanContainer 后创建一个 table。但是,当我尝试 运行 它时,我收到以下错误消息:

java.lang.IllegalStateException: Property RoomID not found

相关代码如下(其中房间可以创建随机房间对象列表)。 Room class 有一个 RoomID 整数,虽然它是一个私有变量,但即使 RoomID 不是私有的,代码也会产生相同的错误。我还确保 r_list 实际上包含 Room 实例。

BeanContainer<Integer, Room> r_cont = new BeanContainer<Integer, Room>(Room.class);
r_cont.setBeanIdProperty("RoomID");

//fetches all rooms and adds them to the bean container
List<Room> r_list = rooms.getRooms();
for (Room room: r_list)
    r_cont.addBean(room);

编辑:这是 Room 对象的 notable 部分。我省略了初始化方法和 setting/getting 其他变量的方法。

package Entities;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

@Entity
@Table(name="Room")
public class Room {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name="RoomID")
    private int RoomID;

    ...

    public int getRoomID(){
        return RoomID;
    }

    ...

}

属性名称不是从持有它的实际变量中扣除的,而是从getter/setter中扣除的。这意味着它应该是 roomId(参见 Where is the JavaBean property naming convention defined?). If you are not sure about the properties you hold, you can debug it on the container with: .getContainerPropertyIds().