Friday, February 04, 2011

attempted to return null from a method with a primitive return type (void).


Problem:
I was encoutering this excpetion while inserting a row in the database using myBatis 3. 

Solution:
I had forgotton to change my mapper file xml tag from <select> to <insert>.

org.apache.ibatis.binding.BindingException: Mapper method 'xxx' (interface in.xx.xxxx..xxxDAO) attempted to return null from a method with a primitive return type (void).
 org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:40)
 $Proxy34.XXXX(Unknown Source)
 xxx.xxx.XXXXServiceImpl.save(XXXServiceImpl.java:94)
 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 java.lang.reflect.Method.invoke(Method.java:597)
 org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309)
 org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
 org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
 org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
 org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
 org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
 org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
 org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopP