Please check this Entity:
@Entity
@Table(name = "css_empresa")
public class Empresa extends EntidadContactable implements Serializable,
Convert {
private static final long serialVersionUID = 1L;
@Id
@SequenceGenerator(name = "EMPRESA_ID_GENERATOR", sequenceName = ConstantesSecuencias.SEQ_EMPRESA, allocationSize = 1)
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "EMPRESA_ID_GENERATOR")
@Column(name = "cod_empresa", unique = true, nullable = false)
private Long id;
@Column(name = "num_ruc", precision = 13)
private BigDecimal numRuc;
@Column(name = "num_rup", precision = 15)
private BigDecimal numRup;
@Column(name = "txt_direccion_web", length = 255)
private String txtDireccionWeb;
@Column(name = "txt_nombre", nullable = false, length = 255)
private String txtNombre;
@Column(name = "txt_observaciones", length = 255)
private String txtObservaciones;
@OneToOne
@JoinColumn(name = "cod_usuario")
private Usuario administrador;
// bi-directional many-to-one association to DireccionEmpresa
@OneToMany(mappedBy = "empresa", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
private List<DireccionEmpresa> direccionEmpresas;
//Getters Setters ommited for brevity
}
Then in my controller I have something like this:
Empresa empresa=entityManager.findById(1L);
empresa.getDireccionEmpresas.remove(direccionEmpresa);
entityManager.merge(empresa);
However this is not deleting the DireccionEmpresa from the Database... why this could be happening?.