Hello,
I have some problem with @OneToMany and @ManyToOne annotations.
I have two class Suite and SuiteVersion. A SuiteVersion is dependent of a suite. So i have implemented this in my code:
Class Suite :
@OneToMany(mappedBy = "suite")
@Cascade(CascadeType.DELETE_ORPHAN)
private List<SuiteVersion> listSuiteVersion = new ArrayList<SuiteVersion>();
Class SuiteVersion :
@ManyToOne()
@Cascade({org.hibernate.annotations.CascadeType.SAVE_UPDATE})
private Suite suite;
But i have some problem when i delete a Suite whose have SuiteVersion associated. Hibernate don't delete SuiteVersion before Suite.I don't know why because i have mentioned this in my code :
@Cascade(CascadeType.DELETE_ORPHAN)
This the log i obtained when i delete suite :
Hibernate: delete from SUITE where ID_SUITE=? 13 août 2010 09:40:50 org.hibernate.util.JDBCExceptionReporter logExceptions ATTENTION: SQL Error: -8, SQLState: 23504 13 août 2010 09:40:50 org.hibernate.util.JDBCExceptionReporter logExceptions GRAVE: integrity constraint violation: foreign key no action; FK42895651EA304E6 table: SUITE_VERSION
Thank you in advance for your help.
Best Regards,
Florent,
P.S : Sorry for my english i'm french.