title: org.springframework.aop.AopInvocationException: Null return value from advice does not match primitive return type for: public abstract char
body: <p>I have a table defined with column char and the repo I have defined a 
  query to return that column. Now when the data in the db table is null 
  for the specific condition its giving me the error: </p>
  
  <pre><code>org.springframework.aop.AopInvocationException: Null return value from 
  advice does not match primitive return type for: public abstract char
  </code></pre>
  
  <p>Below is the code snippet:</p>
  
  <pre><code>    import org.springframework.data.jpa.repository.JpaRepository;
      import org.springframework.data.jpa.repository.Query;
      import org.springframework.data.repository.query.Param;
  
      import com.marriott.sup.beans.StepWorkflow;
  
      public interface flowRepo extends JpaRepository&lt;StepWorkflow, Long&gt; {
  
          @Query(
                  value = "SELECT s.status FROM flow s WHERE s.XREFID 
       = :xrefId order by "
                  + "s.Datestarted desc limit 1",
                  nativeQuery = true)
          public char findLatestSts(@Param("xrefId") Long xrefId);
  
      }
  
      public class flowService {
  
          public static char INPROGRESS = 'P';
          public static char SUCCESS = 'S';
          public static char ERROR = 'E';
          public static char NOTSTARTED = 'N';
  
          @Autowired
          private flowRepo Fl;
  
          /*some basic code in between and then i am trying to call the 
        function 
        defined in repo and assign it to a character variable
      */
  
      Sts = Fl.findLatestSts(xrefId);
      }
  </code></pre>
  
  <p>I need this to not throw the error and instead assign some default value in case null.  Need help to fix the issue on how can I handle this.</p>
  
  <pre><code>org.springframework.aop.AopInvocationException: Null return value from advice does not match primitive return type for: public abstract char org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:226) at com.sun.proxy.$Proxy108.findLatestSts(Unknown Source) at com.marriott.sup.service.StepWorkflowService.getserverStepstatus(StepWorkflowService.java:79) at com.marriott.sup.web.SampleRestController.getServerStepStatus(SampleRestController.java:91) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:189) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:102) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:892) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:797) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1038) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:942) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1005) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:897)
  </code></pre>