Hi Goran, I'm using the MultiSelectBox, as following: An Object "Customer

Hi Goran,

I’m using the MultiSelectBox, as following:
(Using Eclipselink for the JPA stack)

An Object “Customer” can have one or more Objects “Applications”
the multiSelectBox has 3 pre-defined applications in the table

  1. When creating a customer, I choose the 3 pre-defined objects ‘application’, no problem

  2. But When I modify the customer, by un-choosing by example one ‘application’, after saving, this unchoosed Object is ALSO DELETED in the application table

**Why is the unchoosed Object deleted in the application table? **
Many thanks in advance

Model

@Entity
public class Customer {

private Set<Application> applications = new HashSet<Application>();

/**
 * @return the applications
 */
@PrivateOwned	
@OneToMany(cascade = CascadeType.ALL, fetch=FetchType.LAZY)
@OrderBy("name ASC")
public Set<Application> getApplications() {
	return applications;
}

/**
 * @param applications the applications to set
 */
public void setApplications(Set<Application> applications) {
	this.applications = applications;
}

In the View

/*
*

  • using the multiselectBox for choosing applications

*/

MultiselectComboBox applications = new MultiselectComboBox();

applications.setPlaceholder(“Choisissez les produits installés…”);
applications.setWidthFull();
applications.setItemLabelGenerator(Application::getName);

List applicationsList = customerService.getApplications(); // all the objects ‘application’ stored in the table ‘application’
applications.setOrdered(true);

if (applicationsList != null && applicationsList.size()>0) {
applications.setItems(new HashSet<>(applicationsList));
}

applications.setClearButtonVisible(true);
binder.bind(applications, Customer::getApplications, Customer::setApplications);

Hi Christophe,

It’s a bit difficult to follow the above code due to the formatting errors. Could you please provide a minimal reproducible project / repo that demonstrates this issue and is easy to start up locally?

My assumption is that this issue is most likely related to the entity model and how the relations are configured and not a problem in the component itself, but it’s best to verify such assumptions.

BR,

Goran

P.S. This page is for the multiselect-combo-box web component. The Java (flow) wrapper component’s page is this one: https://vaadin.com/directory/component/multiselect-combo-box

Hi Goran,

I just got the solution,
yes, it came from the relation parameters, on the cascatype
thanks for your help anyway
Chris.