How do I, by annotations or methods to exclude, or make a update
in a parent entity without being forced to delete the child entity, eg
public class Produto{
@Id
@GeneratedValue
int id;
//...
@ManyToOne() //fetch.LAZY
Categoria categoria;
}
public class Categoria{
@Id
@GeneratedValue
int id;
//...
@OneToMany(mappedby = "categoria") //fetch.LAZY
Produto produto;
}
I see that my class produto
is the operation's daughter class, the strongest side, which holds% of category%, I would like to be able to delete a category, even if it is related to a product, updating the column foreign key
from table to CATEGORIA_ID
maybe.
But when I try to exclude it it generates an error:
ConstraintViolationException You can not delete or update a record that has a relationship.
I've tried the NULL
property and nothing.