Hello,
I have some problem with delation of associations, this is my code :
Classe ModuleVersion
@ManyToMany(mappedBy="listModuleVersions")
private List<SuiteVersion> suiteVersions = new ArrayList<SuiteVersion>();
Classe SuiteVersion
@ManyToMany()
private List<ModuleVersion> listModuleVersions = new ArrayList<ModuleVersion>();*
I would like to be able to delete automatically a suiteVersion or a moduleVersion with deletion of association. For example, if i delete a SuiteVersion with this code is delete automatically the association SuiteVersion to ModuleVersion. But if i delete a moduleVersion it doesn't automatically delete the association of SuiteVersion -> ModuleVersion. It is possible to do this automatically with ModuleVersion ?
Update
This is the action perform by hibernate if i delete a module with the adding of CASCADETYPE.REMOVE ...
Hibernate: delete from SUITE_VERSION_MODULE_VERSION where suiteVersions_ID_SUITE_VERSION=?
Hibernate: delete from SUITE_VERSION_MODULE_VERSION where suiteVersions_ID_SUITE_VERSION=?
Hibernate: delete from SUITE_VERSION_MODULE_VERSION where suiteVersions_ID_SUITE_VERSION=?
Hibernate: delete from SUITE_VERSION_MODULE_VERSION where suiteVersions_ID_SUITE_VERSION=?
Hibernate: delete from SUITE_VERSION_MODULE_VERSION where suiteVersions_ID_SUITE_VERSION=?
//Hibernate: delete from SUITE_VERSION where ID_SUITE_VERSION=?
//Hibernate: delete from SUITE_VERSION where ID_SUITE_VERSION=?
Hibernate: delete from MODULE_VERSION where ID_MODULE_VERSION=?
//Hibernate: delete from SUITE_VERSION where ID_SUITE_VERSION=?
//Hibernate: delete from SUITE_VERSION where ID_SUITE_VERSION=?
Hibernate: delete from MODULE_VERSION where ID_MODULE_VERSION=?
//Hibernate: delete from SUITE_VERSION where ID_SUITE_VERSION=?
Hibernate: delete from MODULE_VERSION where ID_MODULE_VERSION=?
Hibernate: delete from MODULE where ID_MODULE=?
I just want the part none comitted to be executed. Thank you in advance for your help,
Update2
I tried to delete the module with this method implementation :
public static void removeModule(Module module) {
for(ModuleVersion moduleVersion : module.getListModuleVersion()){
for(SuiteVersion suiteVersion : moduleVersion.getSuiteVersions()){
sessionFactory = HibernateFactory.getSessionFactory();
session = sessionFactory.getCurrentSession();
transaction = session.beginTransaction();
suiteVersion.removeFromModuleVersions(moduleVersion);
transaction.commit();
}
}
sessionFactory = HibernateFactory.getSessionFactory();
session = sessionFactory.getCurrentSession();
session.delete(module);
transaction.commit();
}
But i have this problem now :
Exception in thread "AWT-EventQueue-0" java.util.ConcurrentModificationException
Best regards,
Florent.
P.S: I'm french, sorry for my english.