我试图在自定义查询的帮助下从oracle DB获取结果但是我得到了以下错误,我尝试在实体类中添加时间和列定义但是没有用。
我的数据库表没有任何像id,
这样的唯一列错误讯息**:
2018-03-25 07:29:46.634 ERROR 14800 --- [nio-9000-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 com.mudassir.inlandcy.controller.InlandCYcontroller.postMethodXMLreturnXML3(InlandCYcontroller.java:33) ~[classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_161]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_161]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_161]
at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.8.0_161]
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:209) ~[spring-web-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:136) ~[spring-web-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:102) ~[spring-webmvc-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:870) ~[spring-webmvc-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:776) ~[spring-webmvc-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) ~[spring-webmvc-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:991) ~[spring-webmvc-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:925) ~[spring-webmvc-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:978) ~[spring-webmvc-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:881) ~[spring-webmvc-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:661) ~[tomcat-embed-core-8.5.28.jar:8.5.28]
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:855) ~[spring-webmvc-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:742) ~
存储库查询:
package com.mudassir.inlandcy.dao;
import java.util.Date;
import java.util.List;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.format.annotation.DateTimeFormat.ISO;
import org.springframework.stereotype.Repository;
@Repository
public interface InlandCYRepository extends CrudRepository<INLANDCY, Long> {
@Query("select i from INLANDCY i where HUB_GEOID=:hubgeoid AND EFFECTIVE_DT = TO_DATE(:effectivedate,'dd-mm-yyyy')")
public List<INLANDCY> findInlandCYbytoday (@Param("hubgeoid") String hubgeoid,@Param("effectivedate") Date effectivedate);
}
实体类:
package com.mudassir.inlandcy.dao;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import java.util.Date;
import javax.persistence.Column;
@Entity
public class INLANDCY {
@Id
@Column(name="HUB_GEOID")
private String hubgeoid;
@Temporal(TemporalType.TIMESTAMP)
@Column(name="EFFECTIVE_DT", columnDefinition = "DATETIME")
private Date effective_dt;
@Temporal(TemporalType.TIMESTAMP)
@Column(name="CREATED_DT", columnDefinition = "DATETIME")
private Date createddt;
public INLANDCY() {
super();
// TODO Auto-generated constructor stub
}
public INLANDCY(String hub_geoid, Date effective_dt, Date created_dt) {
super();
this.hubgeoid = hub_geoid;
this.effective_dt = effective_dt;
this.createddt = created_dt;
}
public String getHub_geoid() {
return hubgeoid;
}
public void setHub_geoid(String hub_geoid) {
this.hubgeoid = hub_geoid;
}
public Date getEffective_dt() {
return effective_dt;
}
public void setEffective_dt(Date effective_dt) {
this.effective_dt = effective_dt;
}
public Date getCreated_dt() {
return createddt;
}
public void setCreated_dt(Date created_dt) {
this.createddt = created_dt;
}
@Override
public String toString()
{
return "INLANDCY [HUB_GEOID=" + hubgeoid + ", EFFECTIVE_DT=" + effective_dt + ", CREATED_DT=" + createddt + "]";
}
}
请帮助我,因为我是第一次使用JPA。
由于