Hi,
Basically i have an entity 'FamilleGarantieService' which has a list of 'RisqueCouvert'
RisqueCouvert cannot exist without a FamilleGarantieService.
I have set my database to have 2 RisqueCouvert in my list.
I m trying to remove the first element of the list doing so :
beginTx();
//load from the repository FamilleGarantieService f1 = repos .chercherFamilleGarantieParIdentifiant(FAMILLE_ID1); //get the element we are going to delete RisqueCouvert rco = f1.getRisquesCouverts().get(0);
//delete from the list f1.getRisquesCouverts().remove(rco); commitTx(); beginTx(); f1 = repos .chercherFamilleGarantieParIdentifiant(FAMILLE_ID1);
assertEquals(1, f1.getRisquesCouverts().size()); commitTx();
And then i have a assert fails on the equals, the size is still 2.
My mapping :
@Entity @Table(name = "FamilleGarantieService") public class FamilleGarantieService { [...] /** Les risques couverts */ @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY) @JoinColumn(name="FamilleGarantieService_id",nullable=false) private List<RisqueCouvert> risquesCouverts;
The sql is only select ...
If i modify one of my entities, there is sql update.
If i change nullable=true, there the FK(FamilleGarantieService_id) is set to NULL (and i have a contraint error so)
I can add, i can delete f1 and the RisqueCouvert's elements will be deleted too. If i do entityManager.remove(rco) it s working too.
But what i want to do is list.remove(child) and have a sql delete !
Any idea ?
thanks a lot.
Hibernate version: 3.2
|