Когда я развертываю свой проект Maven с использованием весенней загрузки с IntelliJ Ultimate IDE, я получаю сообщение об ошибке 500,
Wed Jul 10 15:51:03 IST 2019
There was an unexpected error (type=Internal Server Error, status=500).
could not execute statement; SQL [n/a]; nested exception is org.hibernate.exception.SQLGrammarException: could not execute statement
Итак, я предположил, что это может произойти из-за ошибки в моем параметре Date в моем классе контроллера. Я передаю данные следующим образом:
package com.example.test3.controller;
import com.example.test3.model.employee;
import com.example.test3.repo.CustomerRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Date;
@RestController
public class WebController {
@Autowired
CustomerRepository repository;
@RequestMapping("/save")
public String process(){
// save a single employee
repository.save(new employee("Jack", "ekanayakeindrajith@gmail.com", new Date(2099,9,2), "skill1"));
return "Done";
}
}
А в атрибуте даты есть предупреждение,
Дата (int, int, int) устарела
Но все же я не знаю, как правильно его настроить. Я уже ссылался на подобные вопросы в Stackoverflow
Вопрос1
Question2 Но все еще не удается решить эту проблему. Любая помощь будет принята с благодарностью!
Edit:
employee.java
файл выглядит следующим образом,
package com.example.test3.model;
import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
@Entity
@Table(name = "employee")
public class employee implements Serializable {
private static final long serialVersionUID = -3009157732242241606L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private long id;
@Column(name = "fullname")
private String fullname;
@Column(name = "email")
private String email;
@Column(name = "dateofbirth")
private Date dateofbirth;
@Column(name = "skill")
private String skill;
protected employee() {
}
public employee(String fullname, String email, Date dateofbirth, String skill) {
this.fullname = fullname;
this.email = email;
this.dateofbirth=dateofbirth;
this.skill=skill;
}
@Override
public String toString() {
return String.format("employee[id=%d, fullname='%s', email='%s', dateofbirth='%s', skill='%s']", id, fullname, email, dateofbirth, skill);
}
}