最近在做办公自动化的项目,遇到这样的问题java.lang.IllegalArgumentException: id to load isrequired for loading
Struts Problem ReportStruts has detected an unhandled exception:Messages:• id to load is required for loadingFile:org/hibernate/event/LoadEvent.javaLine number:89Stacktracesjava.lang.IllegalArgumentException: id to load is required for loading org.hibernate.event.LoadEvent.(LoadEvent.java:89) org.hibernate.event.LoadEvent.(LoadEvent.java:61) org.hibernate.impl.SessionImpl.get(SessionImpl.java:1002) org.hibernate.impl.SessionImpl.get(SessionImpl.java:998) cn.itcast.oa.base.BaseDaoImpl.getById(BaseDaoImpl.java:52) cn.itcast.oa.base.BaseDaoImpl.detele(BaseDaoImpl.java:38) cn.itcast.oa.service.impl.RoleServiceImpl.detele(RoleServiceImpl.java:23) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) java.lang.reflect.Method.invoke(Method.java:497) org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317) org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190) org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:98) org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:262) org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:95)
这个问题很明显是id没有获取到,但是小编在前台的url链接中已经看到了id的值了,那就是在调用接口的时候没有将id的值获取到.小编就开始断点调试.
在这里报空指针了,而这个是最底层的,那么就是他的上一次没有获取到,层层推进,找到他的上一级,才发现之前写的时候没有实现ModelDriven,直接是实例化了一个新的Role,这样的话,role.getId肯定是null值了.
总结:
其实问题不难,只要静下心来,一步步的分析就能将他解决.