Summary:

References in the Custom_Tables table to non-existent entries on the Custom_Databases table may cause the CRMJ webapp to throw an error on startup.

Symptoms:

The following error is logged to the stdout.log in \CRM\tomcat\logs

 Exception in thread "Thread-13" org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [com.sage.scrm.model.metadata.gen.CustomDatabase#4]
 at org.hibernate.impl.SessionFactoryImpl$2.handleEntityNotFound(SessionFactoryImpl.java:435)
 at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:233)
 at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:285)
 at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:152)
 at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:1090)
 at org.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:1038)
 at org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:630)
 at org.hibernate.type.EntityType.resolve(EntityType.java:438)
 at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:139)
 at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:982)
 at org.hibernate.loader.Loader.doQuery(Loader.java:857)
 at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:274)
 at org.hibernate.loader.Loader.doList(Loader.java:2533)
 at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2276)
 at org.hibernate.loader.Loader.list(Loader.java:2271)
 at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:119)
 at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1716)
 at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:347)
 at com.sage.scrm.model.BasicHelper.getListFromCriteria(BasicHelper.java:124)
 at com.sage.scrm.model.BasicHelper.getListFromCriteria(BasicHelper.java:91)
 at com.sage.scrm.model.BasicHelper.getListOfModifiedObjects(BasicHelper.java:205)
 at com.sage.scrm.model.metadata.MetaDataHelper.getCustomEntities(MetaDataHelper.java:104)
 at com.sage.scrm.model.metadata.MetaDataHelper$$FastClassByCGLIB$$88d7b8c9.invoke(<generated>)
 at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
 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 com.sage.scrm.model.metadata.MetaDataHelper$$EnhancerByCGLIB$$57873d02.getCustomEntities(<generated>)
 at com.sage.scrm.model.metadata.MetaDataStore$1.run(MetaDataStore.java:225)
 at java.lang.Thread.run(Unknown Source)
Exception in thread "Thread-13" org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [com.sage.scrm.model.metadata.gen.CustomDatabase#4]
 at org.hibernate.impl.SessionFactoryImpl$2.handleEntityNotFound(SessionFactoryImpl.java:435)
 at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:233)
 at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:285)
 at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:152)
 at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:1090)
 at org.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:1038)
 at org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:630)
 at org.hibernate.type.EntityType.resolve(EntityType.java:438)
 at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:139)
 at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:982)
 at org.hibernate.loader.Loader.doQuery(Loader.java:857)
 at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:274)
 at org.hibernate.loader.Loader.doList(Loader.java:2533)
 at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2276)
 at org.hibernate.loader.Loader.list(Loader.java:2271)
 at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:119)
 at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1716)
 at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:347)
 at com.sage.scrm.model.BasicHelper.getListFromCriteria(BasicHelper.java:124)
 at com.sage.scrm.model.BasicHelper.getListFromCriteria(BasicHelper.java:91)
 at com.sage.scrm.model.BasicHelper.getListOfModifiedObjects(BasicHelper.java:205)
 at com.sage.scrm.model.metadata.MetaDataHelper.getCustomEntities(MetaDataHelper.java:104)
 at com.sage.scrm.model.metadata.MetaDataHelper$$FastClassByCGLIB$$88d7b8c9.invoke(<generated>)
 at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
 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 com.sage.scrm.model.metadata.MetaDataHelper$$EnhancerByCGLIB$$d084ef96.getCustomEntities(<generated>)
 at com.sage.scrm.model.metadata.MetaDataStore$1.run(MetaDataStore.java:225)
 at java.lang.Thread.run(Unknown Source)

A further SageObjectNotInitializedException CRMJ logs on attempting to view the Interactive Dashboard. This error will also be displayed in the SDATA schema on attempting to browse to the SDATA schema URL.

Cause:

This was caused by an issue with entries on the Custom_Tables table. The Bord_DatabaseID field contained a reference to an entry that did not exist on the Custom_Databases table. The issue was likely caused by hard deleting entries from the Custom_Databases table.

Resolution:

The issue was resolved by soft deleting the entries on Custom_Tables for the problem entries. This was done by setting Bord_Deleted to 1. The entries in question can be identified by running the following SQL:

select * from Custom_Tables
where Bord_DatabaseID is not null
 and Bord_DatabaseID not in (select Cdbo_DatabaseId from Custom_Databases)

Care must be taken not to delete entries on Custom_Tables that are referenced by any other metadata objects in Sage CRM.

More information:

The only recommended or supported method of editing the Sage CRM metadata is through the user interface. Hard deleting items from the database using Management Studio is not recommended.