Handle attribute of type Set in datatable primefaces

1

I have a street, neighborhood and logradouro_bairro table.

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

In the public 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 log entityBrirro, 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'd like to know what would be the best way to add / remove a neighborhood in the datatable I have in the view of the street, create a List of neighborhoods in the street, and manipulate this list with add / remove or use the attribute itself of the public: private Set logradouroBairro = new LinkedHashSet<>(); to iterate in the datatable?

I do not know the best way to do it, I thought about creating an excluded / added flag in the Neighborhood List to identify which neighborhoods should be included / altered in the logradouroBairro attribute, but I believe it is not a good practice.

    
asked by anonymous 04.01.2016 / 13:46

0 answers