My class model contains a class that has relationship tagged with annotations. I took care to use them correctly by adding the famous "cascade=cascadeType.PERSIST". Sometimes it works, but, very often not, I get this error message :
"java.lang.IllegalStateException: During synchronization a new object was found through a relationship that was not marked cascade PERSIST: Model.Donation[id=null]."
I found on several web sites that comes from the library but without more explication...
Thank you for your help
@OneToOne(optional=true, cascade=CascadeType.ALL)
private Localisation localisation;
@ManyToOne(cascade=CascadeType.ALL)
private Device device;
@ManyToOne(cascade=CascadeType开发者_如何学Go.ALL)
private Project project;
As my relationships are bi-directional, I though I only need to set cascadeType to the relationship that manages the relation. But it isn't. By adding cascadeType.ALL to the both sides, it works perfectly!
精彩评论