在Heroku上部署之后的org.hibernate.exception.SQLGrammarException

时间:2017-06-09 11:44:30

标签: java spring hibernate jpa heroku

我在Heroku服务上部署应用程序后出现问题(但在本地计算机上它还能正常运行)

错误信息是:

Possibly unhandled rejection: {"data":{"timestamp":1497005957771,"status":500,"error":"Internal Server Error","exception":"org.springframework.dao.InvalidDataAccessResourceUsageException","message":"could not extract ResultSet; SQL [n/a]; nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet","path":"/reports/by1/2017-06-09"},"status":500,"config":{"method":"GET","transformRequest":[null],"transformResponse":[null],"jsonpCallbackParam":"callback","url":"/reports/by1/2017-06-09","headers":{"Accept":"application/json, text/plain, */*","X-Requested-With":"XMLHttpRequest","X-XSRF-TOKEN":"fd7aca17-d409-4922-85e0-d6b72bc8d6f0"}},"statusText":""}

本地的Hibernate查询是:

Hibernate: select report0_.id as id1_6_, report0_.date as date2_6_, report0_.input as input3_6_, report0_.line_id as line_id4_6_, report0_.output as output5_6_, report0_.register as register6_6_, report0_.shift as shift7_6_ from report report0_ where report0_.line_id=? and report0_.date=?

在线Hibernate查询是:嗯,这是另一个问题,因为我无法读取它错误日志是大的。可能这个问题的答案将是两者的答案:)

Report.class是:

@Entity
@Table(name = "report")
public class Report {

@Id
@GenericGenerator(name = "generator", strategy = "increment")
@GeneratedValue(generator = "generator")
@Column(name = "id", nullable = false)
private Integer id;
@Column(name = "date", nullable = false)
private Date date;
@Column(name = "shift", nullable = false)
private Integer shift;
@Column(name = "register", nullable = false)
private Integer register;
@Column(name = "input", nullable = false)
private Integer input;
@Column(name = "output", nullable = false)
private Integer output;
@Column(name = "line_id", nullable = false)
private Integer lineId;  . . . some code is ommited . . .

App适用于:https://counter-proj2.herokuapp.com/

登录:alex,传递:123456

Git:https://github.com/ajaks84/CP_ver2

任何想法可能是什么原因?

顺便说一下,我非常感谢有关该应用程序的任何评论。

2 个答案:

答案 0 :(得分:1)

有两件事我不喜欢/闻不好。

a)ReportRepo     列出findByLineIdAndDate(整数 line_id ,日期日期);

在repo上你需要使用变量名,而不是列名。可能不是你问题的原因,但看起来很难看。

b)import java.sql.Date;

只有上帝知道heroku数据库如何处理java.sql.Date,这是java历史上最糟糕的实现之一。我将切换到一个简单的java.util.Date甚至是一个Instant,并确保heroku DB使用正确的数据类型

答案 1 :(得分:1)

问题已经解决了。我安装了ConEmu,终于看到了Heroku上发生的错误。那不是关于sql.Date它只是错误的sql脚本。

感谢您的关注。