Form - Entity ComboBox creates incorrect PK class error

Hi,

I am new to Vaadin and I’m using it with Spring Roo.
I created a Form object built with this FormFieldFactory (just paste the code that does not work) :


else if (propertyId.equals("country")) {
	ComboBox countryField = new ComboBox();
	countryField.setCaption("Pays");
	countryField.setImmediate(false);

	// Configure container
	JPAContainer<Country> containerForCountries = new JPAContainer<Country>(Country.class);
	containerForCountries.setEntityProvider(EntityProviderUtil.get().getEntityProvider(Country.class));
	countryField.setContainerDataSource(containerForCountries);
	countryField.setItemCaptionPropertyId("name");
			
	// Configure converter
	Container container = countryField.getContainerDataSource();
	PropertyConverter<Country, Long> converter = new BeanFieldPropertyConverter<Country, Long>(Country.class, container, "id");
	converter.setPropertyDataSource(item.getItemProperty("country"));
	countryField.setPropertyDataSource(converter);
			
	// Configure validator
	this.configureValidators(propertyId, countryField, converter);

	return countryField;
}

More information : an AccidentBean is bind to the form. This AccidentBean has a ManyToOne relationship with the CountryBean.

The problem is that when I select a Country from the combobox and validate my form, I have the following error :

java.lang.IllegalArgumentException: You have provided an instance of an incorrect PK class for this find operation. Class expected : class java.lang.Long, Class received : class com.declasin.entity.Country.

Is it a problem with my converter ?
Thanks in advance for the help :slight_smile:

HI @Chafik H’nini this replay is little late, but sure.
I had this issue and I resolve it using this
http://code.google.com/p/customfield/source/browse/trunk/src/org/vaadin/addon/customfield/demo/ConversionExample.java?r=23

Best regards