爲什麼沒有Spring 3.0.4HibernateTemplate
方法load()
扔DataAccessException
或更具體地說,ObjectRetrievalFailureException
,如果Hibernate 3.3.2GA拋出ObjectNotFoundException
?爲什麼Spring在Hibernate拋出ObjectNotFoundException異常時不拋出DataAccessException?
2010-12-15 13:16:03,939 133247782 [[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'] INFO org.hibernate.event.def.DefaultLoadEventListener - Error performing load command
org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [com.db.spgit.abstrack.model.ConsUsCustomMark#78445AAD8]
at org.hibernate.impl.SessionFactoryImpl$1.handleEntityNotFound(SessionFactoryImpl.java:375) ~[hibernate-3.2.1.ga.jar:3.2.1.ga]
at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:145) ~[hibernate-3.2.1.ga.jar:3.2.1.ga]
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:179) ~[hibernate-3.2.1.ga.jar:3.2.1.ga]
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:103) ~[hibernate-3.2.1.ga.jar:3.2.1.ga]
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:878) [hibernate-3.2.1.ga.jar:3.2.1.ga]
at org.hibernate.impl.SessionImpl.load(SessionImpl.java:795) [hibernate-3.2.1.ga.jar:3.2.1.ga]
at org.hibernate.impl.SessionImpl.load(SessionImpl.java:788) [hibernate-3.2.1.ga.jar:3.2.1.ga]
at org.springframework.orm.hibernate3.HibernateTemplate$3.doInHibernate(HibernateTemplate.java:558) [spring-orm-3.0.4.RELEASE.jar:3.0.4.RELEASE]
at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:406) [spring-orm-3.0.4.RELEASE.jar:3.0.4.RELEASE]
at org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374) [spring-orm-3.0.4.RELEASE.jar:3.0.4.RELEASE]
at org.springframework.orm.hibernate3.HibernateTemplate.load(HibernateTemplate.java:551) [spring-orm-3.0.4.RELEASE.jar:3.0.4.RELEASE]
at org.springframework.orm.hibernate3.HibernateTemplate.load(HibernateTemplate.java:545) [spring-orm-3.0.4.RELEASE.jar:3.0.4.RELEASE]
邁克爾,你是對的!我沒有注意到它是生成這個日誌消息的Hibernate。我誤解了日誌條目意味着Spring事實上並沒有翻譯這個異常。事實上,應用程序沒有傳播這個異常的任何更高的堆棧應該提示我,因爲Spring正確處理了這個異常。 – 2010-12-15 21:57:06