JPA Container/Combo Box/Field Group

Hi,

I am using JPA Container to source my comboBox as below;

Table SnapShot is Below;
I have attached the screenshot of my table.

Code:
ComboBox transName = new ComboBox();
transName.setContainerDataSource(transname);
transName.setItemCaptionPropertyId(“transName”);
System.out.println(transName.getItemIds());
for (Object itemIds : transName.getItemIds()) {
System.out.println(transName.getItemCaption(itemIds));
}
transName.setNullSelectionAllowed(false);

And I am binding this comboBox to my FieldGroup;

    tranFG = new FieldGroup(transItem);
    tranFG.bind(transName, "transName");

While performing Commit, I am getting the following Error;
Caused by: com.vaadin.data.util.converter.Converter$ConversionException: Unable to convert value of type java.lang.Integer to model type class java.lang.String. No converter is set and the types are not compatible.
at com.vaadin.data.util.converter.ConverterUtil.convertToModel(ConverterUtil.java:181)
at com.vaadin.ui.AbstractField.convertToModel(AbstractField.java:745)
… 44 more

Could someone please help me on, how to resolve this issue. Thanks.

Please let me know if more information is required. Thanks.

13548.png

I was able to fix it by changing the code as below;

    ComboBox transName = new ComboBox();
    for (Object itemIds : transname.getItemIds()) {
        transName.addItem(transname.getContainerProperty(itemIds, "transName").getValue().toString());
    }
    transName.setNullSelectionAllowed(false);

Also What I found out in my previous code, even though I change the itemCaption to Property as below;
transName.setItemCaptionPropertyId(“transName”);

combox box getValue method is still returing the “Id” which is Integer. Please let me know if I am missing something. Thanks.