BeanItemContainer with Hibernate POJOs in OptionGroup

I am trying to use an OptionGroup in the following manner with hibernate.

private OptionGroup getOptionGroup(BaseManager manager, boolean multiSelect) {
	OptionGroup og = new OptionGroup();
	og.setMultiSelect(multiSelect);
	og.setItemCaptionPropertyId("name");
	BeanItemContainer container = new BeanItemContainer(
			manager.list());		
	og.setContainerDataSource(container);
	og.setRequired(true);
	return og;
}

After doing a save I am getting the following exception


09:56:30,421 ERROR [STDERR]
Caused by: com.vaadin.data.Property$ConversionException: java.lang.reflect.InvocationTargetException
09:56:30,421 ERROR [STDERR]
at com.vaadin.data.util.MethodProperty.setValue(MethodProperty.java:709)
09:56:30,421 ERROR [STDERR]
at com.vaadin.ui.AbstractField.setValue(AbstractField.java:489)
09:56:30,421 ERROR [STDERR]
… 24 more

From the examples I’ve seen it seems like this is the way a BeanItemContainer is intended to be used, that is managing a list of POJOs. Do I need to add all of the the properties of my POJO to the BeanItemContainer via addContainerProperty? And why is it setting these properties at all?

What is the correct way to render an OptionGroup from a list of POJOs where the POJO has both an ID and a Caption that you’d like to display?

The example looks ok to me. I tested it (after modifying it to work without “BaseManager”) and there is no ConversionException thrown so I guess the problem comes from the code you have not posted.