REF: Binding a ComboBox in a ManyToOne Scenario

I have a Employee and Department relation (@ManyToOne)

Binder<Employee> myFormBinder = new Binder<>(Employee.class); //Form binding

ComboBox<Department> deptComboBox = new ComboBox<>();
deptComboBox.setItems(departmentService.getAllDept()); //Returns an object List<Department>

Now binding this combobox is giving an error

java.lang.RuntimeException: java.lang.IllegalArgumentException: The provided value is not part of ComboBox: at this line:

myFormBinder.bind(deptComboBox, Employee::getDept, Employee::setDept);

The binding is being set as follows:

public void setEmployee(Employee emp){
        this.emp = emp;

What am I missing out to load the ComboBox correctly with correct department of the selected empoloyee

Managed to figure out what was the problem.

There was a type missmatch and also the object Department need the equals method implemented.