Handle Set type attribute in datatable primefaces

Asked

Viewed 56 times

1

I have a street, neighborhood and street table.

logradouro (id, nome)
bairro (id, nome)
logradouro_bairro (id, id_logr, id_bairro)

In the street entity, I have the mapping:

@OneToMany(mappedBy = "logradouro", cascade = CascadeType.ALL)
@Getter
@Setter
private Set logradouroBairro = new LinkedHashSet<>();

In the neighborhood entity, I have the mapping:

@OneToMany(mappedBy = "bairro", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@Getter
@Setter
private Set logradouroBairro = new HashSet<>();

In the entity logradouroBairro, I have the mapping:

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "id_bairro", referencedColumnName = "id", foreignKey = @ForeignKey(name = "fk_logr_id_bairro"))
@Getter
@Setter
private Bairro bairro;

Well, I wonder what would be the most appropriate way to add/remove a neighborhood on the datatable I have in the street view, create a List of neighborhoods in the street, and manipulate this list with add/remove or use the attribute itself from the patio: private Set logradouroBairro = new LinkedHashSet<>(); to iterate in the datatable?

I don’t know the best way to do it, I thought of creating an deleted/added flag in the Neighborhood List to identify which neighbourhoods should be included/changed in the current attribute.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.