Form - Entity ComboBox creates incorrect PK class error


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();

	// Configure container
	JPAContainer<Country> containerForCountries = new JPAContainer<Country>(Country.class);
	// Configure converter
	Container container = countryField.getContainerDataSource();
	PropertyConverter<Country, Long> converter = new BeanFieldPropertyConverter<Country, Long>(Country.class, container, "id");
	// 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

Best regards