Reputation: 17
I'm trying to create a table with a BeanContainer after populating it. However, when I try to run it, I get the following error message:
java.lang.IllegalStateException: Property RoomID not found
The relevant code is below (in which rooms can create a list of random Room objects). The Room class has a RoomID integer, and while it is a private variable the code produces the same error even if RoomID isn't private. I've also made sure that r_list actually contains Room instances.
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);
EDIT: Here's the notable part of the Room object. I left out the initialization method and the methods for setting/getting the other variables.
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;
}
...
}
Upvotes: 0
Views: 1069
Reputation: 37033
The property name is not deducted from the the actual variable holding it, but from the getter/setter. This means it should be roomId
(see e.g. 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()
.
Upvotes: 2