Hi there,
I'm quite lost with the cascade.
I will simplify my stuff in order to ask, so the example is quite stupid :)
I have 3 classes : Human, Clothes and Dressing-Room
So basically the implementation is something like
Code:
@Entity @Table @AndSoOn
class Human {
private List<Cloth> clothes;
@OneToMany(mappedBy = "human", cascade = CascadeType.ALL ?, fetch = FetchType.LAZY)
public List<Cloth> getClothes()
{
return clothes;
}
}
@Entity @Table @AndSoOn
class DressingRoom {
private List<Cloth> clothes;
@OneToMany(mappedBy = "dressingRoom", cascade = CascadeType.???, fetch = FetchType.LAZY)
public List<Cloth> getClothes()
{
return clothes;
}
}
@Entity @Table @AndSoOn
class Cloth {
private Human human;
private DressingRoom dressingRoom;
@ManyToOne
public Human getHuman()
{
return human;
}
@ManyToOne
public DressingRoom getDressingRoom()
{
return dressingRoom;
}
}
What are the good cascade annotations for the following workflow :
If a Human is deleted all his clothes are deleted also
If a DressingRoom is deleted, the clothes are not deleted (dressingRoom become null)
A single Cloth can, of course, be deleted without any impact neither on Human or DressingRoom (I guess I have to play with deleteOrphan for this one, but where ?)
Thanks for any help you could give me