【发布时间】:2016-10-06 11:11:43
【问题描述】:
我有一个对象,我使用 Hibernate 逆向工程向导 和 Hibernate 映射文件和数据库中的 POJO 创建了它。
在这种情况下,我的表有一个 sql 时间字段(reminder_time),但 hibernate 将该字段生成为 java.util.Date 字段。
这是我的桌子,
提到的字段是reminder_time。
这是我的目标,
import java.util.Date;
public class Reminder implements java.io.Serializable {
private Integer idreminder;
private Patient patient;
private String remindAbout;
private Date reminderTime;
private Date reminderDate;
private boolean active;
private boolean repeat;
private Date dateCreated;
private Date lastUpdated;
public Reminder() {
}
public Reminder(Patient patient, String remindAbout, Date reminderTime, Date reminderDate, boolean active, boolean repeat, Date lastUpdated) {
this.patient = patient;
this.remindAbout = remindAbout;
this.reminderTime = reminderTime;
this.reminderDate = reminderDate;
this.active = active;
this.repeat = repeat;
this.lastUpdated = lastUpdated;
}
public Reminder(Patient patient, String remindAbout, Date reminderTime, Date reminderDate, boolean active, boolean repeat, Date dateCreated, Date lastUpdated) {
this.patient = patient;
this.remindAbout = remindAbout;
this.reminderTime = reminderTime;
this.reminderDate = reminderDate;
this.active = active;
this.repeat = repeat;
this.dateCreated = dateCreated;
this.lastUpdated = lastUpdated;
}
public Integer getIdreminder() {
return this.idreminder;
}
public void setIdreminder(Integer idreminder) {
this.idreminder = idreminder;
}
public Patient getPatient() {
return this.patient;
}
public void setPatient(Patient patient) {
this.patient = patient;
}
public String getRemindAbout() {
return this.remindAbout;
}
public void setRemindAbout(String remindAbout) {
this.remindAbout = remindAbout;
}
public Date getReminderTime() {
return this.reminderTime;
}
public void setReminderTime(Date reminderTime) {
this.reminderTime = reminderTime;
}
public Date getReminderDate() {
return this.reminderDate;
}
public void setReminderDate(Date reminderDate) {
this.reminderDate = reminderDate;
}
public boolean isActive() {
return this.active;
}
public void setActive(boolean active) {
this.active = active;
}
public boolean isRepeat() {
return this.repeat;
}
public void setRepeat(boolean repeat) {
this.repeat = repeat;
}
public Date getDateCreated() {
return this.dateCreated;
}
public void setDateCreated(Date dateCreated) {
this.dateCreated = dateCreated;
}
public Date getLastUpdated() {
return this.lastUpdated;
}
public void setLastUpdated(Date lastUpdated) {
this.lastUpdated = lastUpdated;
}
}
当我尝试使用上述对象将一些数据保存到此表中时,出现以下异常,
Oct 06, 2016 4:40:06 PM org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions
ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'repeat, date_created, last_updated) values (3, 'Taking medicine', '15:30:18', '2' at line 1
org.hibernate.exception.SQLGrammarException: could not execute statement
对此有什么想法吗?
【问题讨论】:
-
您的标题与问题无关,请修正。