Note that there are some explanatory texts on larger screens.

plurals
  1. POHibernate, Persistance and delation of associations
    primarykey
    data
    text
    <p>I have some problem with delation of associations, this is my code :</p> <blockquote> <p>Classe ModuleVersion</p> </blockquote> <pre><code>@ManyToMany(mappedBy="listModuleVersions") private List&lt;SuiteVersion&gt; suiteVersions = new ArrayList&lt;SuiteVersion&gt;(); </code></pre> <blockquote> <p>Classe SuiteVersion</p> </blockquote> <pre><code>@ManyToMany() private List&lt;ModuleVersion&gt; listModuleVersions = new ArrayList&lt;ModuleVersion&gt;();* </code></pre> <p>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 ?</p> <p><strong>Update</strong></p> <blockquote> <p>This is the action perform by hibernate if i delete a module with the adding of CASCADETYPE.REMOVE ...</p> </blockquote> <pre><code>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=? </code></pre> <p>I just want the part none comitted to be executed. Thank you in advance for your help,</p> <p><strong>Update2</strong></p> <p>I tried to delete the module with this method implementation :</p> <pre><code> 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(); } </code></pre> <p>But i have this problem now : </p> <pre><code>Exception in thread "AWT-EventQueue-0" java.util.ConcurrentModificationException </code></pre> <p>Best regards,</p> <p>Florent.</p> <p>P.S: I'm french, sorry for my english.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload