Bonjour,
J'utilise une liaison oneToMany entre deux classes Entree et Entser.
Lorsque j'essaye d'ajouter une cascade entre ces deux entitées j'obtiens une exception.
Sans cascade, il n'y a pas de problème, mais il n'y a pas de sauvegarde entre Entree et Entser.
Le problème viens peut être de Spring ?
J'utilise la base oracle avec le driver jdbc 10.2.0.5.0
Voici le mapping des données :
Code:
@Entity
@Table(name = "ENTREE")
public class Entree implements java.io.Serializable {
@GenericGenerator(name = "generator", strategy = "increment")
@GeneratedValue(generator = "generator")
@Id
@Column(name = "REG_ID", unique = true, nullable = false, precision = 7, scale = 0)
public int getRegId() {
return this.regId;
}
public void setRegId(int regId) {
this.regId = regId;
}
[...]
@OneToMany(fetch = FetchType.LAZY, mappedBy = "entree", cascade = CascadeType.ALL)
public Set<Entser> getEntsers() {
return this.entsers;
}
public void setEntsers(Set<Entser> entsers) {
this.entsers = entsers;
}
[...]
}
@Entity
@Table(name = "ENTSER", uniqueConstraints = @UniqueConstraint(columnNames = {
"REG_ID", "SERI_ID", "SSERI_ID", "COMNOT" }))
public class Entser implements java.io.Serializable {
@GenericGenerator(name = "generator", strategy = "increment")
@GeneratedValue(generator = "generator")
@Id
@Column(name = "ENTSER_ID", unique = true, nullable = false, precision = 22, scale = 0)
public BigDecimal getEntserId() {
return this.entserId;
}
public void setEntserId(BigDecimal entserId) {
this.entserId = entserId;
}
[...]
}
Code:
org.springframework.jdbc.UncategorizedSQLException: Hibernate operation: could not load an entity: [fr.sicem.thot.db.Entree#4249]; uncategorized SQLException for SQL [select entree0_.REG_ID as REG1_73_1_, entree0_.ETATE_ID as ETATE43_73_1_, entree0_.NAT_ID as NAT44_73_1_, entree0_.PERS_ID as PERS45_73_1_, entree0_.PERS_ID_CLASSE as PERS46_73_1_, entree0_.PROD_ID as PROD47_73_1_, entree0_.REG_ANA as REG2_73_1_, entree0_.REG_CLASS as REG3_73_1_, entree0_.REG_COMUNIT as REG4_73_1_, entree0_.REG_DAR as REG5_73_1_, entree0_.REG_DCLOTURE as REG6_73_1_, entree0_.REG_DCREA as REG7_73_1_, entree0_.REG_DDEBCL as REG8_73_1_, entree0_.REG_DDIF as REG9_73_1_, entree0_.REG_DENT as REG10_73_1_, entree0_.REG_DESINF as REG11_73_1_, entree0_.REG_DETIQ_D as REG12_73_1_, entree0_.REG_DETIQ_F as REG13_73_1_, entree0_.REG_DEX_D as REG14_73_1_, entree0_.REG_DEX_F as REG15_73_1_, entree0_.REG_DFINCL as REG16_73_1_, entree0_.REG_DIAR as REG17_73_1_, entree0_.REG_DMAJ as REG18_73_1_, entree0_.REG_DSIGNARCH as REG19_73_1_, entree0_.REG_DSIGNDEPO as REG20_73_1_, entree0_.REG_ELECT as REG21_73_1_, entree0_.REG_ETATDATE as REG22_73_1_, entree0_.REG_GENFICHE as REG23_73_1_, entree0_.REG_INSTR as REG24_73_1_, entree0_.REG_METR as REG25_73_1_, entree0_.REG_METRCLASS as REG26_73_1_, entree0_.REG_NBART as REG27_73_1_, entree0_.REG_NBFIC as REG28_73_1_, entree0_.REG_NBUNIT as REG29_73_1_, entree0_.REG_OBS as REG30_73_1_, entree0_.REG_PCLASS as REG31_73_1_, entree0_.REG_PRIX as REG32_73_1_, entree0_.REG_RESPFONCT as REG33_73_1_, entree0_.REG_RESPFOUR as REG34_73_1_, entree0_.REG_RESPSITE as REG35_73_1_, entree0_.REG_SOURCE as REG36_73_1_, entree0_.REG_STOCK as REG37_73_1_, entree0_.REG_TAILLEFIC as REG38_73_1_, entree0_.REG_TYPDOC as REG39_73_1_, entree0_.REG_TYPPRIX as REG40_73_1_, entree0_.REG_UCREA as REG41_73_1_, entree0_.REG_UMAJ as REG42_73_1_, entree0_.TENT_ID as TENT48_73_1_, entree0_.TIR_ID as TIR49_73_1_, entsers1_.REG_ID as REG7_73_3_, entsers1_.ENTSER_ID as ENTSER1_3_, entsers1_.ENTSER_ID as ENTSER1_78_0_, entsers1_.COMNOT as COMNOT78_0_, entsers1_.REG_ID as REG7_78_0_, entsers1_.ENTSER_SERIE_ORDRE as ENTSER3_78_0_, entsers1_.ENTSER_SSERIE_ORDRE as ENTSER4_78_0_, entsers1_.ENTSER_SSSERIE_ORDRE as ENTSER5_78_0_, entsers1_.NBART as NBART78_0_, entsers1_.SERI_ID as SERI8_78_0_, entsers1_.SSERI_ID as SSERI9_78_0_ from ENTREE entree0_ left outer join ENTSER entsers1_ on entree0_.REG_ID=entsers1_.REG_ID where entree0_.REG_ID=?]; SQL state [null]; error code [17027]; Le flux de données est déjà fermé; nested exception is java.sql.SQLException: Le flux de données est déjà fermé
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:83)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
at org.springframework.orm.hibernate3.HibernateAccessor.convertJdbcAccessException(HibernateAccessor.java:424)
at org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:410)
at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:411)
at org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374)
at org.springframework.orm.hibernate3.HibernateTemplate.merge(HibernateTemplate.java:813)
at fr.sicem.thot.dao.hibernate.EntreeDaoImpl.update(EntreeDaoImpl.java:81)
at fr.sicem.thot.services.EntreeService.updateEntree(EntreeService.java:147)
at fr.sicem.thot.services.EntreeService$$FastClassByCGLIB$$8c3ee498.invoke(<generated>)
at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:191)
at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:688)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:621)
at fr.sicem.thot.services.EntreeService$$EnhancerByCGLIB$$8798bdc8.updateEntree(<generated>)
at fr.sicem.thot.services.TestEntreeService.testAddEntser(TestEntreeService.java:117)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74)
at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:82)
at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:240)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:180)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.sql.SQLException: Le flux de données est déjà fermé
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:208)
at oracle.jdbc.driver.LongAccessor.getBytes(LongAccessor.java:151)
at oracle.jdbc.driver.LongAccessor.getString(LongAccessor.java:193)
at oracle.jdbc.driver.T4CLongAccessor.getString(T4CLongAccessor.java:426)
at oracle.jdbc.driver.OracleResultSetImpl.getString(OracleResultSetImpl.java:403)
at oracle.jdbc.driver.OracleResultSet.getString(OracleResultSet.java:1515)
at org.apache.commons.dbcp.DelegatingResultSet.getString(DelegatingResultSet.java:224)
at org.hibernate.type.descriptor.sql.VarcharTypeDescriptor$2.doExtract(VarcharTypeDescriptor.java:61)
at org.hibernate.type.descriptor.sql.BasicExtractor.extract(BasicExtractor.java:64)
at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:253)
at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:249)
at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:229)
at org.hibernate.type.AbstractStandardBasicType.hydrate(AbstractStandardBasicType.java:330)
at org.hibernate.persister.entity.AbstractEntityPersister.hydrate(AbstractEntityPersister.java:2283)
at org.hibernate.loader.Loader.loadFromResultSet(Loader.java:1527)
at org.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:1455)
at org.hibernate.loader.Loader.getRow(Loader.java:1355)
at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:611)
at org.hibernate.loader.Loader.doQuery(Loader.java:829)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:274)
at org.hibernate.loader.Loader.loadEntity(Loader.java:2037)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:86)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:76)
at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:3293)
at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:496)
at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:477)
at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:227)
at org.hibernate.event.def.DefaultLoadEventListener.returnNarrowedProxy(DefaultLoadEventListener.java:318)
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:277)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:152)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:1090)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:1005)
at org.hibernate.event.def.DefaultMergeEventListener.entityIsDetached(DefaultMergeEventListener.java:453)
at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:255)
at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:84)
at org.hibernate.impl.SessionImpl.fireMerge(SessionImpl.java:867)
at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:851)
at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:855)
at org.springframework.orm.hibernate3.HibernateTemplate$23.doInHibernate(HibernateTemplate.java:817)
at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:406)
... 41 more