Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/62.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java JPA查询上的NullPointerException_Java_Mysql_Spring Boot_Jpa_Nullpointerexception - Fatal编程技术网

Java JPA查询上的NullPointerException

Java JPA查询上的NullPointerException,java,mysql,spring-boot,jpa,nullpointerexception,Java,Mysql,Spring Boot,Jpa,Nullpointerexception,正如标题所说,当我调用数据存储库中的方法来检索一些数据时,我得到了一个空指针异常。 我正在使用JPA+Hibernate使用Spring引导框架制作一个API 我检查了方法参数是否为null或空,但所有参数都很好。我还尝试更改查询,但在执行时得到相同的nullPointerException org.springframework.boot spring启动程序父级 2.0.5.1发布 UTF-8 UTF-8 1.8 0.10.5 org.springframework.boot spring

正如标题所说,当我调用数据存储库中的方法来检索一些数据时,我得到了一个空指针异常。 我正在使用JPA+Hibernate使用Spring引导框架制作一个API

我检查了方法参数是否为null或空,但所有参数都很好。我还尝试更改查询,但在执行时得到相同的nullPointerException


org.springframework.boot
spring启动程序父级
2.0.5.1发布
UTF-8
UTF-8
1.8
0.10.5
org.springframework.boot
spring引导启动器数据jpa
这是pom.xml的一部分

此旧查询适用于:

@Query(“从数据d中选择d作为d,其中d.contextSource.id=?1和d.param.id=?2,d.File.id=f.id,f.creationDate介于?3和?4之间,f.labSystem.id=?5和f.sampleType.id=?6按d.File.creationDate asc排序”)
列出findParamData(长contextSourceId、长paramId、java.util.Date开始、java.util.Date结束、长labSystemId、长sampleTypeId);
但是没有日期的新版本不起作用:

@Query(“从数据d、文件f中选择d作为d,其中d.contextSource.id=?1和d.param.id=?2,d.File.id=f.id和f.labSystem.id=?3和f.sampleType.id=?4按d.File.creationDate asc排序”)
列出findPreviousDataEntry(长contextSourceid、长paramId、长labSystemId、长sampleTypeId);
My Data.java类:

包eu.qcloud.data;
导入javax.persistence.Column;
导入javax.persistence.EmbeddedId;
导入javax.persistence.Entity;
导入javax.persistence.EnumType;
导入javax.persistence.Enumerated;
导入javax.persistence.JoinColumn;
导入javax.persistence.manytone;
导入javax.persistence.Table;
导入com.fasterxml.jackson.annotation.JsonIgnore;
导入eu.qcloud.contextSource.contextSource;
导入eu.qcloud.file.file;
导入eu.qcloud.param.param;
导入eu.qcloud.threshold.InstrumentStatus;
@实体
@表(name=“data”)
公共类数据{
@杰索尼奥雷
@嵌入ID
私有数据标识数据标识;
@许多酮
@JoinColumn(name=“paramId”,insertable=false,updateable=false)
私有参数;
@许多酮
@JoinColumn(name=“contextSourceId”,insertable=false,updateable=false)
私有ContextSource ContextSource;
@许多酮
@JoinColumn(name=“fileId”,insertable=false,updateable=false)
私有文件;
私人浮动价值;
私人浮动计算值;
@枚举(EnumType.STRING)
@列(columnDefinition=“varchar(255)默认值‘OK’)
私有InstrumentStatus UnconcentrationyStatus=InstrumentStatus.OK;
公共浮点getValue(){
返回值;
}
公共无效设置值(浮动值){
这个值=值;
}
公共数据(){}
公共数据(Param Param、ContextSource ContextSource、File文件){
this.param=param;
this.contextSource=contextSource;
this.file=文件;
}
公共数据ID getDataId(){
返回数据标识;
}
public void setDataId(DataId DataId){
this.dataId=dataId;
}
公共参数getParam(){
返回参数;
}
公共void setParam(Param Param){
this.param=param;
}
public ContextSource getContextSource(){
返回contextSource;
}
public void setContextSource(ContextSource ContextSource){
this.contextSource=contextSource;
}
公共文件getFile(){
返回文件;
}
公共无效设置文件(文件){
this.file=文件;
}
公共浮点getCalculatedValue(){
if(calculatedValue==null){
返回Float.NaN;
}
返回计算值;
}
公共void setCalculatedValue(浮点calculatedValue){
this.calculatedValue=calculatedValue;
}
公共工具状态GetUnconceptionyStatus(){
返回不一致状态;
}
公共无效设置不符合状态(仪表状态不符合状态){
this.unconcentrationstatus=unconcentrationstatus;
}
}
下面是对该方法的调用:

Long noseya=新长(8);
System.out.println(“CS ID:+this.getContextSourceId());
System.out.println(“LS ID:+this.getLabSystemId());
System.out.println(“ST-ID:+this.getSampleTypeId());
System.out.println(“参数ID:+noseya”);
列表数据=新的ArrayList();
data.addAll(dataRepository.findPreviousDataEntry(getContextSourceId(),noseya,getLabSystemId(),getSampleTypeId());
用于(数据hola:数据){
System.out.println(hola.getValue());
}
最后是异常跟踪:

RetentionTimeDriftProcessor
CS ID: 1
LS ID: 3
ST ID: 1
PARAm ID: 8
2019-04-12 16:01:44.919 ERROR 10993 --- [nio-8083-exec-2] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.NullPointerException] with root cause
java.lang.NullPointerException: null
    at eu.qcloud.data.processor.processors.RetentionTimeDriftProcessor.processData(RetentionTimeDriftProcessor.java:81) ~[classes/:na]
    at eu.qcloud.data.DataService.calculateValueFromGuideSet(DataService.java:515) ~[classes/:na]
    at eu.qcloud.data.DataService.insertDataFromPipeline(DataService.java:384) ~[classes/:na]
    at eu.qcloud.data.DataController.insertDataFromPipeline(DataController.java:162) ~[classes/:na]
    at eu.qcloud.data.DataController$$FastClassBySpringCGLIB$$f95bfd3e.invoke(<generated>) ~[classes/:na]
    at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) ~[spring-core-5.0.9.RELEASE.jar:5.0.9.RELEASE]
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:746) ~[spring-aop-5.0.9.RELEASE.jar:5.0.9.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) ~[spring-aop-5.0.9.RELEASE.jar:5.0.9.RELEASE]
    at org.springframework.security.access.intercept.aopalliance.MethodSecurityInterceptor.invoke(MethodSecurityInterceptor.java:69) ~[spring-security-core-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185) ~[spring-aop-5.0.9.RELEASE.jar:5.0.9.RELEASE]
    at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:688) ~[spring-aop-5.0.9.RELEASE.jar:5.0.9.RELEASE]
    at eu.qcloud.data.DataController$$EnhancerBySpringCGLIB$$bc23b4bc.insertDataFromPipeline(<generated>) ~[classes/:na]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_201]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_201]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_201]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_201]
    at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:209) ~[spring-web-5.0.9.RELEASE.jar:5.0.9.RELEASE]
    at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:136) ~[spring-web-5.0.9.RELEASE.jar:5.0.9.RELEASE]
    at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:102) ~[spring-webmvc-5.0.9.RELEASE.jar:5.0.9.RELEASE]
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:891) ~[spring-webmvc-5.0.9.RELEASE.jar:5.0.9.RELEASE]
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:797) ~[spring-webmvc-5.0.9.RELEASE.jar:5.0.9.RELEASE]
    at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) ~[spring-webmvc-5.0.9.RELEASE.jar:5.0.9.RELEASE]
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:991) ~[spring-webmvc-5.0.9.RELEASE.jar:5.0.9.RELEASE]
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:925) ~[spring-webmvc-5.0.9.RELEASE.jar:5.0.9.RELEASE]
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:974) ~[spring-webmvc-5.0.9.RELEASE.jar:5.0.9.RELEASE]
    at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:877) ~[spring-webmvc-5.0.9.RELEASE.jar:5.0.9.RELEASE]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:661) ~[tomcat-embed-core-8.5.34.jar:8.5.34]
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:851) ~[spring-webmvc-5.0.9.RELEASE.jar:5.0.9.RELEASE]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:742) ~[tomcat-embed-core-8.5.34.jar:8.5.34]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) ~[tomcat-embed-core-8.5.34.jar:8.5.34]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-8.5.34.jar:8.5.34]


保留时间漂移处理器
政务司司长:1
身份证号码:3
ST ID:1
参数ID:8
2019-04-12 16:01:44.919错误10993---[nio-8083-exec-2]o.a.c.c.c.[/].[dispatcherServlet]:路径为[]的上下文中Servlet[dispatcherServlet]的Servlet.service()引发了异常[Request processing failed;嵌套异常为java.lang.NullPointerException],其根本原因是
java.lang.NullPointerException:null
在eu.qcloud.data.processor.processors.RetentionTimeFloftProcessor.processData(RetentionTimeFloftProcessor.java:81)~[classes/:na]
在eu.qcloud.data.DataService.calculateValueFromGuideSet(DataService.java:515)~[classes/:na]
在eu.qcloud.data.DataService.insertDataFromPipeline(DataService.java:384)~[classes/:na]
在eu.qcloud.data.DataController.insertDataFromPipeline(DataController.java:162)~[classes/:na]
在eu.qcloud.data.DataController$$FastClassBySpringCGLIB$$f95bfd3e.invoke()~[classes/:na]
在org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)~[spring-core-5.0.9.RELEASE.jar:5.0.9.RELEASE]
在org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:746)~[spring-aop-5.0.9.RELEASE.jar:5.0.9.RELEASE]
在org.springfra