Hibernate中的布尔映射问题+;MySQL
我知道关于这件事有很多话题,但我还是无法解决我的问题 这是实体类:Hibernate中的布尔映射问题+;MySQL,mysql,hibernate,spring-mvc,hibernate-mapping,Mysql,Hibernate,Spring Mvc,Hibernate Mapping,我知道关于这件事有很多话题,但我还是无法解决我的问题 这是实体类: @Entity @Table(name = "messages") public class Message { .... @Column(name = "read", nullable = false, columnDefinition = "TINYINT(1)") private boolean read; .... public boolean isRead() { return read; } public
@Entity
@Table(name = "messages")
public class Message
{
....
@Column(name = "read", nullable = false, columnDefinition = "TINYINT(1)")
private boolean read;
....
public boolean isRead()
{
return read;
}
public void setRead(boolean read)
{
this.read = read;
}
在messages
MySQL表中,read
列被键入为tinyint(1)
。在将对象保存到表之前,我设置setRead(true)
。当我通过Hibernate(save()
)保存对象时,出现以下错误:
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: 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, senderId, title) values ('ujhjg', 1, 1, 'W pustyni i w puszczy')'
我使用jdbc.dialent=org.hibernate.dialent.mysql5innodbdialent
并尝试了几种方法通过更改布尔字段的注释来解决我的问题,但都不起作用
我的映射出了什么问题,以及如何使其工作
感谢您的帮助和宝贵时间;) 单词
read
是MySQLs保留的关键字之一。检查一下桌子。用另一个名字来避免这种情况。我的问题答案越简单,我就越觉得自己愚蠢:看起来你为我节省了很多时间和压力。干杯