Bonjour,
Depuis que j'ai changé mon mapping pour ajouter une composite id sur la classe DonneeBlocUnivers; j'obtiens une exception lorsque je persiste la classe DonneeBlocUnivers.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 java.lang.ClassCastException: java.lang.String at org.hibernate.type.EntityType.toLoggableString(EntityType.java:154) at org.hibernate.type.ComponentType.toLoggableString(ComponentType.java:333) at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:106) at org.hibernate.event.def.DefaultPersistEventListener.entityIsTransient(DefaultPersistEventListener.java:131) at org.hibernate.event.def.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:87) at org.hibernate.event.def.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:38) at org.hibernate.impl.SessionImpl.firePersist(SessionImpl.java:623) at org.hibernate.impl.SessionImpl.persist(SessionImpl.java:599) at org.hibernate.impl.SessionImpl.persist(SessionImpl.java:603) at com.francetelecom.acp.dao.impl.DonneeBlocUniversDAOImplTest.onSetUpInTransaction(DonneeBlocUniversDAOImplTest.java:124) at org.springframework.test.AbstractTransactionalSpringContextTests.onSetUp(AbstractTransactionalSpringContextTests.java:219) at org.springframework.test.AbstractSingleSpringContextTests.setUp(AbstractSingleSpringContextTests.java:101) at junit.framework.TestCase.runBare(TestCase.java:132) at org.springframework.test.ConditionalTestCase.runBare(ConditionalTestCase.java:76) at junit.framework.TestResult$1.protect(TestResult.java:110) at junit.framework.TestResult.runProtected(TestResult.java:128) at junit.framework.TestResult.run(TestResult.java:113) at junit.framework.TestCase.run(TestCase.java:124) at junit.framework.TestSuite.runTest(TestSuite.java:232) at junit.framework.TestSuite.run(TestSuite.java:227) at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Mapping :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 <class name="com.xxx.yyy.dao.pojo.Univers" table="T_UNIVERS"> <id name="code" column="UNV_CODE" /> <property name="libelle" column="UNV_LIBELLE" /> </class> <class name="com.xxx.yyy.dao.pojo.Bloc" table="T_BLOCS" lazy="true"> <id name="code" column="BLOC_CODE" /> <property name="libelle" column="BLOC_LIBELLE" /> <set name="univers" lazy="true" table="TJ_BLOC_UNV"> <key> <column name="BLOC_CODE" /> </key> <many-to-many column="UNV_CODE" class="com.xxx.yyy.dao.pojo.Univers"/> </set> </class> <class name="com.xxx.yyy.dao.pojo.DonneeBlocUnivers" table="T_DONNEES_FONCTIONNELLE" lazy="false"> <composite-id> <key-many-to-one name="codeBloc" class="com.xxx.yyy.dao.pojo.Bloc"> <column name="BLOC_CODE"></column> </key-many-to-one> <key-property name="codeDonnee" column="FCT_CODE" /> <key-many-to-one name="codeUnivers" class="com.xxx.yyy.dao.pojo.Univers"> <column name="UNV_CODE"></column> </key-many-to-one> </composite-id> </class>Merci d'avance
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 public class DonneeBlocUnivers implements Serializable { private static final long serialVersionUID = 1271248329351132648L; private String codeBloc; private String codeDonnee; private String codeUnivers; /** * @return the codeBloc */ public String getCodeBloc() { return codeBloc; } /** * @param codeBloc the codeBloc to set */ public void setCodeBloc(String codeBloc) { this.codeBloc = codeBloc; } /** * @return the codeDonnee */ public String getCodeDonnee() { return codeDonnee; } /** * @param codeDonnee the codeDonnee to set */ public void setCodeDonnee(String codeDonnee) { this.codeDonnee = codeDonnee; } /** * @return the codeUnivers */ public String getCodeUnivers() { return codeUnivers; } /** * @param codeUnivers the codeUnivers to set */ public void setCodeUnivers(String codeUnivers) { this.codeUnivers = codeUnivers; } /* (non-Javadoc) * @see java.lang.Object#hashCode() */ @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((codeBloc == null) ? 0 : codeBloc.hashCode()); result = prime * result + ((codeDonnee == null) ? 0 : codeDonnee.hashCode()); result = prime * result + ((codeUnivers == null) ? 0 : codeUnivers.hashCode()); return result; } /* (non-Javadoc) * @see java.lang.Object#equals(java.lang.Object) */ @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; final DonneeBlocUnivers other = (DonneeBlocUnivers) obj; if (codeBloc == null) { if (other.codeBloc != null) return false; } else if (!codeBloc.equals(other.codeBloc)) return false; if (codeDonnee == null) { if (other.codeDonnee != null) return false; } else if (!codeDonnee.equals(other.codeDonnee)) return false; if (codeUnivers == null) { if (other.codeUnivers != null) return false; } else if (!codeUnivers.equals(other.codeUnivers)) return false; return true; } }
Partager