Hi there,
We have a system in production which uses Hibernate 3.1.3.
Owing to the legacy data model, a number of our mapped many-to-one columns are often not found in the foreign table.
With 3.1.3 the "not-found" attribute in the many-to-one element stopped Hibernate from blowing up when the FK was dangling/didn't point to an instance in the foreign table. Everything works hunky dory.
I've just swapped out 3.1.3 with the latest 3.2 release candidate and have kept everything as is. I tried to run a few test cases, and am seeing the following exception being thrown when a FK column is null and hence doesn't resolve.
Without spending all night trying to find my way thru the source to find out what's going on:
1) is anyone else using not-found in many-to-one with 3.2? If so - all OK with you?
2) it looks like there's an "EntityNotFoundDelegate" which has been introduced into the codebase. Do I need to prod this somehow/implement a custom delegate to deal with non-existant/dangling FK relationships such as the one in the exception below?
Any advice appreciated!!
JC
Code:
org.springframework.orm.hibernate3.HibernateObjectRetrievalFailureException: No row with the given identifier exists: [com.foo.domain.Office#OfficeCode / null]; nested exception is org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [com.foo.domain.Office#OfficeCode / null]org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [com.foo.domain.Office#OfficeCode / null] at org.hibernate.impl.SessionFactoryImpl$1.handleEntityNotFound(SessionFactoryImpl.java:375) at org.hibernate.event.def.DefaultLoadEventListener.returnNarrowedProxy(DefaultLoadEventListener.java:221) at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:185) at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:101) 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:266) at org.hibernate.type.EntityType.resolve(EntityType.java:303) at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:116) at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:842) at org.hibernate.loader.Loader.doQuery(Loader.java:717) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224) at org.hibernate.loader.Loader.doList(Loader.java:2144) at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2028) at org.hibernate.loader.Loader.list(Loader.java:2023) at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:95) at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1569) at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:283) at org.springframework.orm.hibernate3.HibernateTemplate$37.doInHibernate(HibernateTemplate.java:988) at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:366) at org.springframework.orm.hibernate3.HibernateTemplate.findByCriteria(HibernateTemplate.java:978) at org.springframework.orm.hibernate3.HibernateTemplate.findByCriteria(HibernateTemplate.java:971) at com.foo.db.dao.hibernate.HibernatePlanDAO.findByGsIds(HibernatePlanDAO.java:78) at com.foo.db.dao.hibernate.HibernatePlanDAOTest.testFindByGsIds(HibernatePlanDAOTest.java:66)
[/code]