Probleme hibernate modification d'une clé primaire
Bonjour à tous, j'espere que vous pourriez m'aider à trouver une solution :
en essayant d'effectuer une modification sur l'identifiant d'une classe, j'obtiens l'exception suivante
Citation:
org.hibernate.HibernateException: identifier of an instance of dao.type_activite.TypeActivite was altered from aU4 to aU5
at org.hibernate.event.def.DefaultFlushEntityEventListener.checkId(DefaultFlushEntityEventListener.java:58)
at org.hibernate.event.def.DefaultFlushEntityEventListener.getValues(DefaultFlushEntityEventListener.java:164)
at org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:120)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:196)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:76)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:26)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
at dao.type_activite_unilog.ITypeActiviteUnilogImpl.update(ITypeActiviteUnilogImpl.java:54)
at dao.test.TestJUnit.testUpdate(TestJUnit.java:107)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:421)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:305)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:186)
voici la classe :
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
|
public class TypeActivite {
private String typeActU;
private String libelleTypeActU;
private Set typesActivites;
public TypeActiviteUnilog(){
}
public TypeActivite(String typeActU, String libelleTypeActU) {
super();
this.typeActU = typeActU;
this.libelleTypeActU = libelleTypeActU;
}
public String getTypeActU() {
return typeActU;
}
public void setTypeActU(String typeActU) {
this.typeActU = typeActU;
}
public String getLibelleTypeActU() {
return libelleTypeActU;
}
public void setLibelleTypeActU(String libelleTypeActU) {
this.libelleTypeActU = libelleTypeActU;
}
/**
* @return Returns the typesActivites.
*/
public Set getTypesActivites() {
return typesActivites;
}
/**
* @param typesActivites The typesActivites to set.
*/
public void setTypesActivites(Set typesActivites) {
this.typesActivites = typesActivites;
}
} |
et voici le mapping hibernate :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| <?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>
<class name="dao.TypeActivite" table="TYPEACTU">
<id name="typeActU" column="TYPEACTU">
<generator class="assigned"/>
</id>
<property name="libelleTypeActU" column="LIBELLE"/>
<set name="typesActivites">
<key column="TYPEACTU"/>
<one-to-many class="dao.type_activite.TypeActivite"/>
</set>
</class>
</hibernate-mapping> |
Qlq'un a-t-il une idée pour resoudre ce probleme?
Merci d'avance