欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

hibernate char类型setter的异常情况

程序员文章站 2022-03-17 12:17:08
...
使用hibernate,出错如下:

[DEBUG] 2009-03-04 09:31:32 [http-8098-1] org.hibernate.jdbc.AbstractBatcher.log(AbstractBatcher.java:393) select this_.ASSET_ID as ASSET1_8_0_, this_.description as descript2_8_0_, this_.status as status8_0_, this_.ASSET_TYPE as ASSET4_8_0_, this_.ASSET_NAME as ASSET5_8_0_, this_.STORE_TYPE as STORE6_8_0_, this_.PROVIDER_NO as PROVIDER7_8_0_, this_.ASSET_CODING as ASSET8_8_0_, this_.ASTC_ATTRIBUTE_ID as ASTC9_8_0_, this_.ASTC_ATTRIBUTE_NAME as ASTC10_8_0_, this_.PRODUCT_TYPE as PRODUCT11_8_0_, this_.LANGUAGE_TYPE as LANGUAGE12_8_0_, this_.singer as singer8_0_, this_.IS_ENCRYPTION as IS14_8_0_, this_.ENCRYPTION_METHOD as ENCRYPTION15_8_0_, this_.PLAY_LENGTH as PLAY16_8_0_ from N_ASSET this_ [DEBUG] 2009-03-04 09:31:32 [http-8098-1] org.hibernate.jdbc.AbstractBatcher.log(AbstractBatcher.java:393) select this_.ASSET_ID as ASSET1_8_0_, this_.description as descript2_8_0_, this_.status as status8_0_, this_.ASSET_TYPE as ASSET4_8_0_, this_.ASSET_NAME as ASSET5_8_0_, this_.STORE_TYPE as STORE6_8_0_, this_.PROVIDER_NO as PROVIDER7_8_0_, this_.ASSET_CODING as ASSET8_8_0_, this_.ASTC_ATTRIBUTE_ID as ASTC9_8_0_, this_.ASTC_ATTRIBUTE_NAME as ASTC10_8_0_, this_.PRODUCT_TYPE as PRODUCT11_8_0_, this_.LANGUAGE_TYPE as LANGUAGE12_8_0_, this_.singer as singer8_0_, this_.IS_ENCRYPTION as IS14_8_0_, this_.ENCRYPTION_METHOD as ENCRYPTION15_8_0_, this_.PLAY_LENGTH as PLAY16_8_0_ from N_ASSET this_ [DEBUG] 2009-03-04 09:31:32 [http-8098-1] org.hibernate.jdbc.AbstractBatcher.log(AbstractBatcher.java:393) select this_.ASSET_ID as ASSET1_8_0_, this_.description as descript2_8_0_, this_.status as status8_0_, this_.ASSET_TYPE as ASSET4_8_0_, this_.ASSET_NAME as ASSET5_8_0_, this_.STORE_TYPE as STORE6_8_0_, this_.PROVIDER_NO as PROVIDER7_8_0_, this_.ASSET_CODING as ASSET8_8_0_, this_.ASTC_ATTRIBUTE_ID as ASTC9_8_0_, this_.ASTC_ATTRIBUTE_NAME as ASTC10_8_0_, this_.PRODUCT_TYPE as PRODUCT11_8_0_, this_.LANGUAGE_TYPE as LANGUAGE12_8_0_, this_.singer as singer8_0_, this_.IS_ENCRYPTION as IS14_8_0_, this_.ENCRYPTION_METHOD as ENCRYPTION15_8_0_, this_.PLAY_LENGTH as PLAY16_8_0_ from N_ASSET this_ Hibernate: select this_.ASSET_ID as ASSET1_8_0_, this_.description as descript2_8_0_, this_.status as status8_0_, this_.ASSET_TYPE as ASSET4_8_0_, this_.ASSET_NAME as ASSET5_8_0_, this_.STORE_TYPE as STORE6_8_0_, this_.PROVIDER_NO as PROVIDER7_8_0_, this_.ASSET_CODING as ASSET8_8_0_, this_.ASTC_ATTRIBUTE_ID as ASTC9_8_0_, this_.ASTC_ATTRIBUTE_NAME as ASTC10_8_0_, this_.PRODUCT_TYPE as PRODUCT11_8_0_, this_.LANGUAGE_TYPE as LANGUAGE12_8_0_, this_.singer as singer8_0_, this_.IS_ENCRYPTION as IS14_8_0_, this_.ENCRYPTION_METHOD as ENCRYPTION15_8_0_, this_.PLAY_LENGTH as PLAY16_8_0_ from N_ASSET this_ [WARN ] 2009-03-04 09:31:32 [http-8098-1] org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:528) Unhandled Exception thrown: class org.springframework.orm.hibernate3.HibernateSystemException 2009-3-4 9:31:32 org.apache.catalina.core.StandardWrapperValve invoke 严重: Servlet.service() for servlet action threw exception java.lang.IllegalArgumentException 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:597) at org.hibernate.property.BasicPropertyAccessor$BasicSetter.set(BasicPropertyAccessor.java:42) at org.hibernate.tuple.entity.AbstractEntityTuplizer.setPropertyValues(AbstractEntityTuplizer.java:337) at org.hibernate.tuple.entity.PojoEntityTuplizer.setPropertyValues(PojoEntityTuplizer.java:200) at org.hibernate.persister.entity.AbstractEntityPersister.setPropertyValues(AbstractEntityPersister.java:3499) at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:129) 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$5.doInHibernate(HibernateTemplate.java:539) at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:372) at org.springframework.orm.hibernate3.HibernateTemplate.loadAll(HibernateTemplate.java:535) at com.dtv.cdp.play.dao.AssetDAO.getAllAssets(AssetDAO.java:25) at com.dtv.cdp.play.service.AssetManager.getAllAssets(AssetManager.java:26) at com.dtv.cdp.play.service.AssetManager$$FastClassByCGLIB$$d6e3179c.invoke() at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149) at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:695) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:139) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:107) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:161) at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:630) at com.dtv.cdp.play.service.AssetManager$$EnhancerByCGLIB$$f8f384dc.getAllAssets() at com.dtv.cdp.play.action.AssetAction.list(AssetAction.java:45) at com.dtv.cdp.core.action.BaseAction.unspecified(BaseAction.java:111) at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:249) at com.dtv.cdp.core.action.BaseAction.dispatchMethod(BaseAction.java:102) at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:187) at com.dtv.cdp.core.action.BaseAction.execute(BaseAction.java:91) at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431) at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236) at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196) at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414) at javax.servlet.http.HttpServlet.service(HttpServlet.java:690) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:96) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447) at java.lang.Thread.run(Thread.java:619) 


分析、处理::
对于我的bean类,其属性类型含integer、string、char类型,用最笨的方法逐个删除检查,前两个都没问题,暂停;
再看bean类,含两个类型为char的属性,会不会是他们出了问题?(在前面的开发中,有过设置为char类型、并且存取都正常无误的,就没往这上面想)
删除两属性后,ok,找到问题所在。可是其他的bean怎么没问题呢?在于此bean对应的表数据是人为造就,char类型的字段有些没有设值,会不会和这有关呢?
Update所有char字段有值,通过。
Ft,这个东西搞了我一个小时。

//javaeye和Google关系真是好啊,几乎以最快的速度收录了javaeye所有及最新的内容,我也奉献一点点,希望能对遇到同样问题的朋友有些许帮助。