i got the exception below when the client application (RCP) tries to access the database.
the database is the backend of an old legacy system and has some inconsistent data. e.g. for a many-to-one relation it's possible that a foreign key exists without it's related primary key.
now i don't want hibernate to throw an exception if this would happen. i found the attribute "optional" for the many-to-one annotation, but it seems this is ignored for some reason.
i set "optional=true" for the case i described above, but i still got the exception.
better explanation: of course i want an exception but i'd like to catch it in my application while hibernate should continue eager fetching.
the example of my annotation:
Code:
@ManyToOne (targetEntity=ams.ingres.model.PvStamp.class, fetch=FetchType.EAGER, optional=true)
i'm using eclipse3.1, hibernate tools3.1alpha5, jbosside1.5m2, jbossas4.0.3RC1 (with ejb3.0), jdk1.5update3.
what could i do to solve this problem?
best regards
patrik
Hibernate version: 3.1beta3
Mapping documents:none, i'm using anntotations
Code between sessionFactory.openSession() and session.close():none, i'm using CMT
Full stack trace of any exception that occurs:Code:
15:26:26,770 INFO [DefaultLoadEventListener] Error performing load command
org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [ams.ingres.model.Om
Okopf#679750]
at org.hibernate.ObjectNotFoundException.throwIfNull(ObjectNotFoundException.java:27)
at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:121)
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:170)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:82)
at org.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:661)
at org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:270)
at org.hibernate.type.EntityType.resolve(EntityType.java:305)
at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:105)
at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:791)
at org.hibernate.loader.Loader.doQuery(Loader.java:689)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:221)
at org.hibernate.loader.Loader.loadCollection(Loader.java:1699)
at org.hibernate.loader.collection.CollectionLoader.initialize(CollectionLoader.java:36)
at org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPers
ister.java:490)
at org.hibernate.event.def.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultI
nitializeCollectionEventListener.java:60)
at org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:1437)
at org.hibernate.collection.AbstractPersistentCollection.forceInitialization(AbstractPersistentColl
ection.java:313)
at org.hibernate.engine.StatefulPersistenceContext.initializeNonLazyCollections(StatefulPersistence
Context.java:775)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:226)
at org.hibernate.loader.Loader.doList(Loader.java:1858)
at org.hibernate.loader.Loader.list(Loader.java:1842)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:407)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:273)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:850)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)
at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:41)
at ams.ingres.model.facade.AkteFacade.getAllPvStamp(AkteFacade.java:50)
at ams.ingres.model.facade.AkteFacade.getAllAkten(AkteFacade.java:85)
at ams.beans.stateless.AktenBean.getAllAkten(AktenBean.java:29)
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 org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:99)
at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:33)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:66)
at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:134)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:72)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:3
9)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:63)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:93)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
at org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:183)
at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:107)
at org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(AOPRemotingInvocationHandler.java
:69)
at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:325)
at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:201)
at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:259)
at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:313)
at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:147)
15:26:26,830 INFO [STDOUT] org.hibernate.ObjectNotFoundException: No row with the given identifier
exists: [ams.ingres.model.OmOkopf#679750]
at org.hibernate.ObjectNotFoundException.throwIfNull(ObjectNotFoundException.java:27)
at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:121)
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:170)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:82)
at org.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:661)
at org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:270)
at org.hibernate.type.EntityType.resolve(EntityType.java:305)
at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:105)
at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:791)
at org.hibernate.loader.Loader.doQuery(Loader.java:689)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:221)
at org.hibernate.loader.Loader.loadCollection(Loader.java:1699)
at org.hibernate.loader.collection.CollectionLoader.initialize(CollectionLoader.java:36)
at org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPers
ister.java:490)
at org.hibernate.event.def.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultI
nitializeCollectionEventListener.java:60)
at org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:1437)
at org.hibernate.collection.AbstractPersistentCollection.forceInitialization(AbstractPersistentColl
ection.java:313)
at org.hibernate.engine.StatefulPersistenceContext.initializeNonLazyCollections(StatefulPersistence
Context.java:775)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:226)
at org.hibernate.loader.Loader.doList(Loader.java:1858)
at org.hibernate.loader.Loader.list(Loader.java:1842)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:407)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:273)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:850)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)
at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:41)
at ams.ingres.model.facade.AkteFacade.getAllPvStamp(AkteFacade.java:50)
at ams.ingres.model.facade.AkteFacade.getAllAkten(AkteFacade.java:85)
at ams.beans.stateless.AktenBean.getAllAkten(AktenBean.java:29)
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 org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:99)
at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:33)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:66)
at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:134)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:72)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:3
9)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:63)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:93)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
at org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:183)
at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:107)
at org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(AOPRemotingInvocationHandler.java
:69)
at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:325)
at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:201)
at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:259)
at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:313)
at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:147)
Name and version of the database you are using:computer associates ingres 2.6
The generated SQL (show_sql=true):Code:
08:44:42,359 INFO [STDOUT] Hibernate: select pvstamp0_.ident as ident4_, pvstamp0_.REVISION as REVISION76_4_, pvstamp0_.STATUS as STATUS76_4_, pvstamp0_.ANMELDUNG as ANMELDUNG76_4_, pvstamp0_.KENNUNG as KENNUNG76_4_, pvstamp0_.REFERENZ as REFERENZ76_4_, pvstamp0_.AENDER_DATUM as AENDER7_76_4_, pvstamp0_.AENDER_NAME as AENDER8_76_4_, pvstamp0_.AKTENZEICHEN as AKTENZEI9_76_4_, pvstamp0_.ANZAHL_FAMILIEN as ANZAHL10_76_4_, pvstamp0_.ANZAHL_FRISTEN as ANZAHL11_76_4_, pvstamp0_.ANZAHL_STAEMME as ANZAHL12_76_4_, pvstamp0_.AUFRECHT as AUFRECHT76_4_, pvstamp0_.AUSGABE as AUSGABE76_4_, pvstamp0_.BEKANNTMACHUNG as BEKANNT15_76_4_, pvstamp0_.BEKANNTMACHUNG_ART as BEKANNT16_76_4_, pvstamp0_.BEKANNTMACHUNG_NUMMER as BEKANNT17_76_4_, pvstamp0_.BESCHLUSS_51 as BESCHLUSS18_76_4_, pvstamp0_.ERFASS_DATUM as ERFASS19_76_4_, pvstamp0_.ERFASS_NAME as ERFASS20_76_4_, pvstamp0_.ERTEILUNG as ERTEILUNG76_4_, pvstamp0_.FREIGABE as FREIGABE76_4_, pvstamp0_.FRIST1 as FRIST23_76_4_, pvstamp0_.FRIST2 as FRIST24_76_4_, pvstamp0_.FRIST3 as FRIST25_76_4_, pvstamp0_.IDENT_NATPH as IDENT26_76_4_, pvstamp0_.JG_EINTRAG as JG27_76_4_, pvstamp0_.KATEGORIE_1 as KATEGORIE28_76_4_, pvstamp0_.KATEGORIE_2 as KATEGORIE29_76_4_, pvstamp0_.KATEGORIE_3 as KATEGORIE30_76_4_, pvstamp0_.KATEGORIE_4 as KATEGORIE31_76_4_, pvstamp0_.KENNUNG_IDENT as KENNUNG32_76_4_, pvstamp0_.LAND as LAND76_4_, pvstamp0_.LAND_IDENT as LAND34_76_4_, pvstamp0_.LFDNR as LFDNR76_4_, pvstamp0_.MODUL_IDENT as MODUL36_76_4_, pvstamp0_.NAT_ANMELDUNG as NAT37_76_4_, pvstamp0_.NATIONALE_PHASE as NATIONALE38_76_4_, pvstamp0_.OFFENLEGUNG as OFFENLE39_76_4_, pvstamp0_.OFFENLEGUNG_ART as OFFENLE40_76_4_, pvstamp0_.OFFENLEGUNG_NUMMER as OFFENLE41_76_4_, pvstamp0_.PATENT_ART as PATENT42_76_4_, pvstamp0_.PATENT_NUMMER as PATENT43_76_4_, pvstamp0_.PCT_AKTENZEICHEN as PCT44_76_4_, pvstamp0_.PRIORITAET as PRIORITAET76_4_, pvstamp0_.PRUEFUNGSANTRAG as PRUEFUN46_76_4_, pvstamp0_.PRUEFUNGSFRIST as PRUEFUN47_76_4_, pvstamp0_.PRZ as PRZ76_4_, pvstamp0_.PRZ_IDENT as PRZ49_76_4_, pvstamp0_.REG_51_6_ERTEILUNG as REG50_76_4_, pvstamp0_.REG_PAT_AN as REG51_76_4_, pvstamp0_.REG_PAT_NUMMER as REG52_76_4_, pvstamp0_.SCHLAGWORT as SCHLAGWORT76_4_, pvstamp0_.SESSION_IDENT as SESSION54_76_4_, pvstamp0_.STAMMANMELDUNG as STAMMAN55_76_4_, pvstamp0_.TECHNISCHE_ABTEILUNG as TECHNISCHE56_76_4_, pvstamp0_.UEBERSETZUNG_ART as UEBERSE57_76_4_, pvstamp0_.UEBERSETZUNG_NUMMER as UEBERSE58_76_4_, omocros1_.cross_1 as cross13_6_, omocros1_.OBJEKT as OBJEKT6_, omocros1_.OBJEKT as OBJEKT0_, omocros1_.AENDER_DATUM as AENDER2_72_0_, omocros1_.AENDER_NAME as AENDER3_72_0_, omocros1_.ERFASS_DATUM as ERFASS4_72_0_, omocros1_.ERFASS_NAME as ERFASS5_72_0_, omocros1_.CROSS_1 as CROSS6_72_0_, omocros1_.objekt as objekt72_0_, omocros1_.cross_1 as cross13_72_0_, omocros1_.ART_1 as ART7_72_0_, omocros1_.ART_2 as ART8_72_0_, omocros1_.CROSS_2 as CROSS9_72_0_, omocros1_.CROSSTYP as CROSSTYP72_0_, omocros1_.FOLGE as FOLGE72_0_, omokopf2_.OBJEKT as OBJEKT1_, omokopf2_.STATUS as STATUS73_1_, omokopf2_.AENDER_DATUM as AENDER3_73_1_, omokopf2_.AENDER_NAME as AENDER4_73_1_, omokopf2_.ERFASS_DATUM as ERFASS5_73_1_, omokopf2_.ERFASS_NAME as ERFASS6_73_1_, omokopf2_.BESCHREIBUNG as BESCHREI7_73_1_, omokopf2_.ADRESSNR_SENDER as ADRESSNR8_73_1_, omokopf2_.AKTION_DATUM as AKTION9_73_1_, omokopf2_.AKTION_NAME as AKTION10_73_1_, omokopf2_.ANLAGE_DATUM as ANLAGE11_73_1_, omokopf2_.ANLAGE_NAME as ANLAGE12_73_1_, omokopf2_.DISIS_CONTROL as DISIS13_73_1_, omokopf2_.DISIS_READY as DISIS14_73_1_, omokopf2_.DISIS_TIMING as DISIS15_73_1_, omokopf2_.DK_COUNT as DK16_73_1_, omokopf2_.DOKART_IDENT as DOKART17_73_1_, omokopf2_.GLIEDERUNG as GLIEDERUNG73_1_, omokopf2_.IDENT_VORLAGE as IDENT19_73_1_, omokopf2_.LOCK_CONTROL as LOCK20_73_1_, omokopf2_.PAGECOUNT1 as PAGECOUNT21_73_1_, omokopf2_.PAGECOUNT2 as PAGECOUNT22_73_1_, omokopf2_.QUELLSYSTEM as QUELLSY23_73_1_, omokopf2_.SESSIONID_C as SESSIONID24_73_1_, omokopf2_.SESSIONID_M as SESSIONID25_73_1_, omokopf2_.STATUS_DATUM as STATUS26_73_1_, omokopf2_.STATUS_MAIDENT as STATUS27_73_1_, omokopf2_.TYP_IDENT as TYP28_73_1_, omopos3_.objekt as objekt7_, omopos3_.IDENT as IDENT7_, omopos3_.IDENT as IDENT2_, omopos3_.FILENAME as FILENAME74_2_, omopos3_.AENDER_DATUM as AENDER3_74_2_, omopos3_.AENDER_NAME as AENDER4_74_2_, omopos3_.ERFASS_DATUM as ERFASS5_74_2_, omopos3_.ERFASS_NAME as ERFASS6_74_2_, omopos3_.objekt as objekt74_2_, omopos3_.FILESIZE as FILESIZE74_2_, omopos3_.BESCHREIBUNG as BESCHREI8_74_2_, omopos3_.OBJEKT as OBJEKT74_2_, omopos3_.FOLGE as FOLGE74_2_, omopos3_.TYP_IDENT as TYP11_74_2_, omopos3_.PFAD_IDENT as PFAD12_74_2_, omopos3_.SUBTYP_IDENT as SUBTYP13_74_2_, legalentit4_.ADRESSNR as ADRESSNR3_, legalentit4_.ADIDENT as ADIDENT71_3_, legalentit4_.NAME1 as NAME3_71_3_, legalentit4_.NAME2 as NAME4_71_3_, legalentit4_.KURZNAME as KURZNAME71_3_ from PV_STAMP pvstamp0_ left outer join OM_OCROS omocros1_ on pvstamp0_.ident=omocros1_.cross_1 left outer join OM_OKOPF omokopf2_ on omocros1_.objekt=omokopf2_.OBJEKT left outer join OM_OPOS omopos3_ on omokopf2_.OBJEKT=omopos3_.objekt left outer join AD_STAMM legalentit4_ on omokopf2_.ADRESSNR_SENDER=legalentit4_.ADRESSNR where pvstamp0_.ident=?
08:44:42,520 INFO [DefaultLoadEventListener] Error performing load command
Debug level Hibernate log excerpt: