Beginner |
 |
Joined: Mon May 07, 2007 11:12 pm Posts: 20
|
Hello,
I get the exception below when trying to persist an associated object that is added to an existing object. The parent object is called Service and the associated object is called ServiceConfig. I have pasted the code below for the respective objects and their maps
Hibernate version: 3.2.3
Mapping documents:
<hibernate-mapping default-lazy="false" >
<class name="org.openiam.idm.srvc.service.dto.Service" table="SERVICE" >
<comment></comment>
<id name="serviceId" type="string">
<column name="SERVICE_ID" length="20" />
<generator class="assigned" />
</id>
<property name="serviceName" type="string">
<column name="SERVICE_NAME" length="40">
<comment></comment>
</column>
</property>
<set name="serviceConfigs" inverse="true">
<key>
<column name="SERVICE_ID" length="20">
<comment></comment>
</column>
</key>
<one-to-many class="org.openiam.idm.srvc.service.dto.ServiceConfig" />
</set>
</class>
</hibernate-mapping>
<hibernate-mapping default-lazy="false">
<class name="org.openiam.idm.srvc.service.dto.ServiceConfig" table="service_config">
<comment></comment>
<id name="serviceConfigId" type="string">
<column name="SERVICE_CONFIG_ID" length="20" />
<generator class="assigned" />
</id>
<many-to-one name="service" class="org.openiam.idm.srvc.service.dto.Service" fetch="select">
<column name="SERVICE_ID" length="20">
<comment></comment>
</column>
</many-to-one>
<property name="name" type="string">
<column name="NAME" length="40">
<comment></comment>
</column>
</property>
<property name="value" type="string">
<column name="VALUE" length="40">
<comment></comment>
</column>
</property>
</class>
</hibernate-mapping>
DAO Code
public Service merge(Service detachedInstance) {
log.debug("merging Service instance");
try {
Service result = (Service) sessionFactory.getCurrentSession()
.merge(detachedInstance);
log.debug("merge successful");
return result;
} catch (RuntimeException re) {
log.error("merge failed", re);
throw re;
}
}
Full stack trace of any exception that occurs:
org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [org.openiam.idm.srvc.service.dto.ServiceConfig#101]
at org.hibernate.impl.SessionFactoryImpl$1.handleEntityNotFound(SessionFactoryImpl.java:377)
at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:145)
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:179)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:103)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:878)
at org.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:846)
at org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:557)
at org.hibernate.type.EntityType.resolve(EntityType.java:379)
at org.hibernate.type.EntityType.replace(EntityType.java:259)
at org.hibernate.type.CollectionType.replaceElements(CollectionType.java:451)
at org.hibernate.type.CollectionType.replace(CollectionType.java:518)
at org.hibernate.type.TypeFactory.replace(TypeFactory.java:461)
at org.hibernate.event.def.DefaultMergeEventListener.copyValues(DefaultMergeEventListener.java:340)
at org.hibernate.event.def.DefaultMergeEventListener.entityIsDetached(DefaultMergeEventListener.java:267)
at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:120)
at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:53)
at org.hibernate.impl.SessionImpl.fireMerge(SessionImpl.java:677)
at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:661)
at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:665)
at org.openiam.idm.srvc.service.service.ServiceDAOImpl.merge(ServiceDAOImpl.java:88)
at org.openiam.idm.srvc.service.service.ServiceMgr.updateService(ServiceMgr.java:62)
at org.openiam.idm.srvc.service.service.ServiceMgr$$FastClassByCGLIB$$b04ac9ee.invoke(<generated>)
at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:695)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:139)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:107)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:161)
at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:630)
at org.openiam.idm.srvc.service.service.ServiceMgr$$EnhancerByCGLIB$$c7c35c6a.updateService(<generated>)
at org.openiam.idm.srvc.service.ServiceMgrTest.testAddServiceConfig(ServiceMgrTest.java:127)
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:164)
at junit.framework.TestCase.runBare(TestCase.java:130)
at org.springframework.test.ConditionalTestCase.runBare(ConditionalTestCase.java:69)
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:120)
at junit.framework.TestSuite.runTest(TestSuite.java:228)
at junit.framework.TestSuite.run(TestSuite.java:223)
at org.junit.internal.runners.OldTestClassRunner.run(OldTestClassRunner.java:35)
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)
Name and version of the database you are using:MySQL
|
|