我尝试在我的应用程序中添加新类。一切都很好,直到我添加Boolean read
。当我把它添加到我的班级时,我得到:
We got the following 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 'read tinyint(1) default 0, constraint ck_event_type check (' at line 7 [ERROR:1064, SQLSTATE:42000], while trying to run this SQL script:
以及脚本的重要部分:
create table event (
id bigint auto_increment not null,
type varchar(14) not null,
user_id bigint,
message varchar(255) not null,
date date,
read tinyint(1) default 0,
constraint ck_event_type check (type in ('game_started','game_completed','wrong_answer','correct_answer','wrong_location')),
constraint pk_event primary key (id))
我不知道问题是什么。我在其他类中声明了布尔值,没有问题。我正在使用play 2.2.1
我的课程:
package models;
import java.sql.Date;
import java.util.*;
import javax.persistence.*;
import play.db.ebean.*;
import com.avaje.ebean.*;
import play.data.validation.Constraints.*;
@Entity
public class Event extends Model{
@Id
public Long id;
@Enumerated(EnumType.STRING)
@Column(nullable = false)
public EVENT_TYPE type;
@ManyToOne
public User user;
@Column
public Date date;
@Column(nullable = false)
public String message;
@Column
public Boolean read;
public Event(User user, String message, EVENT_TYPE type, Date date) {
//this.user = user;
//this.message = message;
//this.type = type;
//this.date = date;
//read = false;
}
}