I have a unidirectional relation between two entities and I want to remove property object from join table only. I tried this but it only removes the property object from template and not from database join table. How can I remove it from join table:
template.getProperties().remove(property);
Entity calss:
@Table(name = "template")
public class GridTemplate {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Basic(optional = false)
@Column(name = "id_grid")
@ManyToMany(cascade = CascadeType.ALL)
@JoinTable(name = "grid_property",
joinColumns =
@JoinColumn(name = "id_grid", referencedColumnName = "id"),
inverseJoinColumns =
@JoinColumn(name = "id_property", referencedColumnName = "id"))
private List<Property> properties;
}
join table:
CREATE TABLE [dbo].[grid_property](
[id_grid] [int] NOT NULL,
[id_property] [int] NOT NULL,
CONSTRAINT [PK_grid_property] PRIMARY KEY CLUSTERED
(
[id_grid] ASC,
[id_property] ASC)