Bind ComboBox to the nested property using JPAContainer

I got stuck with a serious (honestly may be just for me) problem. I am trying to bind a value of the selected item in the combo to nested property of the class Address. ComboBox was filled with objects that represent state items but actually are instances of the CategoryItem class.
The problem actually is that Combo operates with item identifier, which has type Long (CategoryItem.id) so ComboBox.setValue & ComboBox.getValue demand that and after selecting an item it firing an event that results in attempt to bind Long to CategoryItem in the itemDataSource.


@Entity
public class CategoryItem  implements Serializable {

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name="id")
	private Long id;
	
	@Version
	@Column(name = "version")
	private Integer version;
	
    @NotNull
    @ManyToOne(cascade=CascadeType.PERSIST)
    @JoinColumn
	private CategoryType categoryType;
	    
    @NotNull
    @Size(min = 1, max= 2000)
    @Column(length=2000)
    private String value;
}


@ Entity
public class Address implements Serializable {
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name="id")
	private Long id;
	
	@Version
	@Column(name = "version")
	private Integer version;

    @ManyToOne(cascade=CascadeType.ALL)
    @JoinColumn 
	private CategoryItem state;

here is how i am creating the form



private EntityItem<Address> itemDataSource;
	
private JPAContainer<CategoryItem> categoryItemContainer = new JPAContainer<CategoryItem>(CategoryItem.class);

//add the nested property in the container
itemDataSource.addNestedContainerProperty("address.state");
// create form
final Form addressForm = new Form();
addressForm.setCaption("Address");
addressForm.setWriteThrough(true); // We use the buffering of the EntityItem instead
addressForm.setFormFieldFactory(new AddressFieldFactory());
addressForm.setItemDataSource(itemDataSource);
addressForm.setVisibleItemProperties(new String[] {
		"address.city", "address.streetName",
		"address.zipCode", "address.state"
		});

here is the the FieldFactory code that creates combo & fills it with items from categoryItemContainer



@SuppressWarnings("serial")
private class AddressFieldFactory extends DefaultFieldFactory {
	final ComboBox states = new ComboBox("State");

        public AddressFieldFactory() {
        	categoryItemContainer.removeAllFilters();
        	categoryItemContainer.addFilter(Filters.eq("categoryType.type", "ADDRESS_STATE"));
        	states.setWidth(COMMON_FIELD_WIDTH);
        	states.setFilteringMode(ComboBox.FILTERINGMODE_STARTSWITH);
        	states.setNullSelectionAllowed(false);
        	states.setContainerDataSource(categoryItemContainer);
        	states.setItemCaptionPropertyId("value");

        	states.addListener(	new Property.ValueChangeListener() {      		
        	
        		public void valueChange(ValueChangeEvent event) {
					getWindow().showNotification("Selected Item: " + event.getProperty());
					
					//itemDataSource.getItemProperty("debtor.address.state").setValue(event.getProperty());
				}
            });       	
        	
        	

        }

        @Override
        public Field createField(Item item, Object propertyId, Component uiContext) {
            if ("address.state".equals(propertyId)) {
            	CategoryItem ci = (CategoryItem)item.getItemProperty(propertyId).getValue();
            	states.setValue(ci.getId());
                return states;
            }
      }
}