Problème de mapping hibernate
Bonjour,
je travaille sur une application qui gère des versions des schémas techniques. J'ai deux tables :
- groupes de schémas techniques (GST)
- schémas techniques (ST)
Un ST est présent dans un et un seul GST. Un ST peut avoir un ST prédécesseur et plusieurs ST successeurs. Ceci afin de gérer les dépendances entre les versions.
Un GST contient une liste de ST. Un GST a également un ST de référence.
J'ai donc 2 fichiers hibernates :
- Groupes de schémas techniques
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
|
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
<hibernate-mapping>
<!--
Created by the Middlegen Hibernate plugin 2.2
http://boss.bekk.no/boss/middlegen/
http://www.hibernate.org/
-->
<class
name="org.sakaiproject.sseRdfs.model.rdfs.SseRdfsGroup"
table="SSE_RDFS_GROUP"
lazy="false"
>
<id
name="id"
type="long"
column="ID"
>
<generator class="native">
<param name="sequence">SSE_RDFS_GROUP_SEQUENCE</param>
</generator>
</id>
<property
name="name"
type="java.lang.String"
column="NAME"
not-null="true"
length="255"
/>
<property
name="description"
type="java.lang.String"
column="DESCRIPTION"
length="255"
/>
<property
name="createdon"
type="java.sql.Date"
column="CREATEDON"
length="7"
/>
<property
name="createdby"
type="java.lang.String"
column="CREATEDBY"
length="30"
/>
<!-- Associations -->
<!-- bi-directional many-to-one association to SseRdf -->
<many-to-one
name="rdfsReference"
class="org.sakaiproject.sseRdfs.model.rdfs.SseRdfs"
not-null="false"
cascade="all"
>
<column name="FK_SSE_RDFS_GROUP_REF" />
</many-to-one>
<!-- bi-directional one-to-many association to SseRdf -->
<set
name="rdfsList"
lazy="false"
inverse="true"
cascade="all"
>
<key>
<column name="FK_SSE_RDFS_GROUP_ID" />
</key>
<one-to-many
class="org.sakaiproject.sseRdfs.model.rdfs.SseRdfs"
/>
</set>
</class>
</hibernate-mapping> |
- Schémas techniques :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
|
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
<hibernate-mapping>
<!--
Created by the Middlegen Hibernate plugin 2.2
http://boss.bekk.no/boss/middlegen/
http://www.hibernate.org/
-->
<class
name="org.sakaiproject.sseRdfs.model.rdfs.SseRdfs"
table="SSE_RDFS"
lazy="false"
>
<id
name="id"
type="long"
column="ID"
>
<generator class="native">
<param name="sequence">SSE_RDFS_SEQUENCE</param>
</generator>
</id>
<property
name="name"
type="java.lang.String"
column="NAME"
not-null="true"
length="100"
/>
<property
name="version"
type="java.lang.String"
column="VERSION"
not-null="true"
length="10"
/>
<property
name="uri"
type="java.lang.String"
column="URI"
not-null="true"
length="150"
/>
<property
name="createdby"
type="java.lang.String"
column="CREATEDBY"
not-null="true"
length="36"
/>
<property
name="description"
type="java.lang.String"
column="DESCRIPTION"
length="255"
/>
<property
name="createdon"
type="java.sql.Date"
column="CREATEDON"
length="7"
/>
<!-- Associations -->
<!-- bi-directional one-to-many association to SseRdf -->
<set
name="successors"
lazy="true"
inverse="true"
cascade="all"
>
<key>
<column name="FK_SSE_RDFS_ID_ANCESTOR" />
</key>
<one-to-many
class="org.sakaiproject.sseRdfs.model.rdfs.SseRdfs"
/>
</set>
<!-- bi-directional many-to-one association to SseRdf -->
<many-to-one
name="predecessor"
class="org.sakaiproject.sseRdfs.model.rdfs.SseRdfs"
not-null="true"
>
<column name="FK_SSE_RDFS_ID_ANCESTOR" />
</many-to-one>
<many-to-one
name="group"
class="org.sakaiproject.sseRdfs.model.rdfs.SseRdfsGroup"
not-null="true"
cascade="persist,merge,evict"
>
<column name="FK_SSE_RDFS_GROUP_ID" />
</many-to-one>
</class>
</hibernate-mapping> |
Mon problème est le suivant :
Lorsque je veux modifier le schéma de référence, j'ai l'erreur suivante : "a different object with the same identifier value was already associated with the session"
Lorsque je veux supprimer un schéma technique qui est la référence du groupe, alors j'ai un message d'erreur me disant : "deleted object would be re-saved by cascade".
J'ai surement du mal configurer mes fichiers hibernate. J'ai essayé plusieurs méthodes mais je n'arrive toujours pas à résoudre ce problème lié aux schémas de référence.
Merci pour vos réponses