Hello, my problem is the next, I have an object of type User, wich contains a set of objects of type UserCalendar, to make the relation between User and Calendar. I maintaine the UserCalendar table from both sides, User and Calendar, with no inverse. I have no problem doing this with an Oracle9 DB.
Now I want to prepare units test, so I'm using hsqldb, and having the unsave transient instance problem.
Can anyone help me??
Mapping documents:
<hibernate-mapping>
<class table="USUARIO" name="com.gmv.sgi.agenda.core.modelo.usuario.Usuario">
<id name="id" type="java.lang.Long" column="ID">
<generator class="native"/>
</id>
<set cascade="all,delete-orphan" order-by="id" lazy="true" name="usuarioTarea">
<key column="ID_USUARIO"/>
<one-to-many class="com.gmv.sgi.agenda.core.modelo.tarea.UsuarioTarea"/>
</set>
<set cascade="all,delete-orphan" order-by="id" lazy="true" name="usuarioAgenda">
<key column="ID_USUARIO"/>
<one-to-many class="com.gmv.sgi.agenda.core.modelo.contacto.UsuarioAgenda"/>
</set>
<set cascade="save-update,delete-orphan" order-by="id" lazy="true" name="usuarioCalendario">
<key column="ID_USUARIO"/>
<one-to-many class="com.gmv.sgi.agenda.core.modelo.calendario.UsuarioCalendario"/>
</set>
<set cascade="delete-orphan" order-by="id" name="usuarioGrupo">
<key column="ID_USUARIO"/>
<one-to-many class="com.gmv.sgi.agenda.core.modelo.usuario.UsuarioGrupo"/>
</set>
<property name="ldapUid" column="LDAP_UID" not-null="true"/>
<many-to-one column="ID_PERMISO" cascade="none" lazy="false" not-null="true" name="permiso"/>
<one-to-one name="config" lazy="false" constrained="false" cascade="all"/>
</class>
</hibernate-mapping>
<hibernate-mapping>
<class table="USUARIO_CALENDARIO" name="com.gmv.sgi.agenda.core.modelo.calendario.UsuarioCalendario">
<id name="id" type="java.lang.Long" column="ID">
<generator class="native"/>
</id>
<many-to-one column="ID_PERMISO" cascade="none" not-null="true" name="permiso"/>
<many-to-one column="ID_CALENDARIO" cascade="save-update" lazy="false" not-null="false" name="calendario"/>
<many-to-one column="ID_USUARIO" cascade="none" not-null="true" name="usuario"/>
<one-to-one name="config" constrained="false" cascade="all"/>
</class>
</hibernate-mapping>
<hibernate-mapping>
<class table="CALENDARIO" name="com.gmv.sgi.agenda.core.modelo.calendario.Calendario">
<id name="id" type="java.lang.Long" column="ID">
<generator class="native"/>
</id>
<set cascade="all-delete-orphan" order-by="id" lazy="true" name="calendarioCita">
<key column="ID_CALENDARIO"/>
<one-to-many class="com.gmv.sgi.agenda.core.modelo.calendario.CalendarioCita"/>
</set>
<set inverse="false" cascade="all,delete-orphan" order-by="id" lazy="true" name="grupoCalendario">
<key column="ID_CALENDARIO"/>
<one-to-many class="com.gmv.sgi.agenda.core.modelo.calendario.GrupoCalendario"/>
</set>
<set inverse="false" cascade="save-update,delete-orphan" order-by="id" lazy="true" name="usuarioCalendario">
<key column="ID_CALENDARIO"/>
<one-to-many class="com.gmv.sgi.agenda.core.modelo.calendario.UsuarioCalendario"/>
</set>
<property name="descripcion" column="DESCRIPCION" not-null="false"/>
<property name="nombre" column="NOMBRE" not-null="true"/>
</class>
</hibernate-mapping>
Full stack trace of any exception that occurs:
Hibernate: call identity()
org.springframework.dao.InvalidDataAccessApiUsageException: object references an unsaved transient instance - save the transient instance before flushing: com.gmv.sgi.agenda.core.modelo.contacto.UsuarioAgenda; nested exception is org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: com.gmv.sgi.agenda.core.modelo.contacto.UsuarioAgenda
org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: com.gmv.sgi.agenda.core.modelo.contacto.UsuarioAgenda
at org.hibernate.engine.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:216)
at org.hibernate.collection.AbstractPersistentCollection.getOrphans(AbstractPersistentCollection.java:889)
at org.hibernate.collection.PersistentSet.getOrphans(PersistentSet.java:51)
at org.hibernate.engine.CollectionEntry.getOrphans(CollectionEntry.java:328)
at org.hibernate.engine.Cascade.deleteOrphans(Cascade.java:336)
at org.hibernate.engine.Cascade.cascadeCollectionElements(Cascade.java:318)
at org.hibernate.engine.Cascade.cascadeCollection(Cascade.java:185)
at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:160)
at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:108)
at org.hibernate.engine.Cascade.cascade(Cascade.java:248)
at org.hibernate.event.def.AbstractSaveEventListener.cascadeAfterSave(AbstractSaveEventListener.java:410)
at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:299)
at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:167)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:101)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:186)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:175)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:98)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:520)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:513)
at org.hibernate.engine.CascadingAction$1.cascade(CascadingAction.java:134)
at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:213)
at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:157)
at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:108)
at org.hibernate.engine.Cascade.cascade(Cascade.java:248)
at org.hibernate.event.def.AbstractSaveEventListener.cascadeBeforeSave(AbstractSaveEventListener.java:385)
at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:242)
at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:167)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:101)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:186)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:175)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:98)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:520)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:513)
at org.hibernate.engine.CascadingAction$1.cascade(CascadingAction.java:134)
at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:213)
at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:157)
at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:108)
at org.hibernate.engine.Cascade.cascadeCollectionElements(Cascade.java:290)
at org.hibernate.engine.Cascade.cascadeCollection(Cascade.java:185)
at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:160)
at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:108)
at org.hibernate.engine.Cascade.cascade(Cascade.java:248)
at org.hibernate.event.def.AbstractSaveEventListener.cascadeAfterSave(AbstractSaveEventListener.java:410)
at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:299)
at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:167)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:101)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:186)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:175)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:98)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:520)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:513)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:509)
at org.springframework.orm.hibernate3.HibernateTemplate$18.doInHibernate(HibernateTemplate.java:693)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:366)
at org.springframework.orm.hibernate3.HibernateTemplate.saveOrUpdate(HibernateTemplate.java:690)
at com.gmv.sgi.sbcore.dao.hibernate.AbstractDAOHibernate.save(AbstractDAOHibernate.java:34)
at com.gmv.sgi.sbcore.service.impl.BaseDAOService.save(BaseDAOService.java:43)
at sun.reflect.GeneratedMethodAccessor16.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:287)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:181)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:148)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:176)
at $Proxy1.save(Unknown Source)
at com.gmv.sgi.agenda.core.service.basic.UsuarioBasicService.save(UsuarioBasicService.java:80)
at com.gmv.sgi.agenda.core.service.high.UsuarioHighService.save(UsuarioHighService.java:194)
at com.sgi.agenda.core.test.FirstTest.testSaveRecord(FirstTest.java:226)
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:585)
at junit.framework.TestCase.runTest(TestCase.java:168)
at junit.framework.TestCase.runBare(TestCase.java:134)
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.OldTestClassRunner.run(OldTestClassRunner.java:76)
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)
|