java.lang.NullPointerException

错误:

java.lang.NullPointerException
    at com.iwater.workbench.data.service.impl.ResidentServiceImpl.updateResident(ResidentServiceImpl.java:568)
    at com.iwater.workbench.data.service.impl.ResidentServiceImpl$$FastClassBySpringCGLIB$$39f18b72.invoke(<generated>)
    at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749)
    at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:367)
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:118)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749)
    at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691)
    at com.iwater.workbench.data.service.impl.ResidentServiceImpl$$EnhancerBySpringCGLIB$$ea559486.updateResident(<generated>)
    at com.iwater.workbench.data.controller.ResidentController.batchGenerateAppAccount(ResidentController.java:491)
    at com.iwater.workbench.data.controller.ResidentController$$FastClassBySpringCGLIB$$6dcc97bc.invoke(<generated>)
    at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
    at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:687)
    at com.iwater.workbench.data.controller.ResidentController$$EnhancerBySpringCGLIB$$3c23b7a4.batchGenerateAppAccount(<generated>)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190)
    at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138)
    at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:878)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:792)
    at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040)
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
    at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:626)

原因:

resident 实体中没有定义id,用BeanUtils.copyProperties()赋值后,resident的id为空,后面代码用到id后报错。

resident = {Resident@18097} 
 residentCode = "1006050231"
 residentName = "宋莉"
 residentMobile = "15532986800"
 roomType = null
 residentAddr = "信都区八一大街七十九号院41号楼1单元1302"
 idCard = null
 bankCard = null
 areaId = "1346356111208755202"
 buildingId = null
 roomNum = null
 isEnabled = {Integer@18689} 1
 isDeleted = null
 createUser = null
 createTime = {Date@18690} "Tue Jan 05 16:57:37 CST 2021"
 updateUser = null
 updateTime = null
 description = null
 companyId = null
 isCharge = {Integer@18689} 1
 residentId = "1346380319620046940"
 areaName = "1.79号院东区(79号院49#50#51#).桥西"
 watermeterId = null
 meterModelId = null
 meterCode = null
 transferCode = null
 collectorCode = null
 installPosition = null
 concentratorId = null
 collectorId = null
 concentratorCode = null
 roomAcreage = null
 roomFloor = null
 invoiceTaxCode = null
 invoiceTaxName = null
 abbreviation = null
 familyNumber = null
 residentCategory = null
 residentTel = null
 homeownerCode = null
 underOfOffice = null
 loginId = "1588435036025946114"
 id = null
 SuperEntity.createTime = null
 SuperEntity.updateTime = null
 log = {StdOutImpl@18694}     

解决:

resident.setId(Long.parseLong(residentVO.getId()));

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值