我想在关系表上使用其他参数和不同的主键建立JPA关系ManyToMany,我仍然会收到以下错误:有人可以帮助我吗?谢谢
您的SQL语法有错误;检查手册 对应于您的MariaDB服务器版本,以获得正确的语法 接近'顺序INT(11)not null auto_increment, idPoint INT(11), idPolygo'在第2行
@Entity
@Table(name = "Point")
public class Point implements Serializable{
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
@Column(name = "idPoint", columnDefinition = "INT(11)", nullable = false)
private int idPoint;
@Column(name = "lat", columnDefinition = "DOUBLE(10,8) ", nullable = true)
private double lat;
@Column(name = "lng", columnDefinition = "DOUBLE(10,8)", nullable = true)
private double lng;
//relationship OneToMany with table PolygonHasPoint
@OneToMany(mappedBy="point")
private Set<PolygonHasPoint> polygonHasPoint;
}
@Entity
@Table(name = "Polygon")
public class Polygon implements Serializable{
//primary key : idPolygon
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
@Column(name = "idPolygon", columnDefinition = "INT(11)", nullable = false)
private int idPolygon;
//relationship OneToMany with table PolygonHasPoint
@OneToMany(mappedBy="polygon")
private Set<PolygonHasPoint> polygonHasPoint;
}
@Entity(name="Point_Polygon")
@Table(name = "Polygon_Point")
public class PolygonHasPoint implements Serializable{
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(name = "order", columnDefinition = "INT(11)", nullable = false)
private int order;
@ManyToOne
@JoinColumn(name = "idPoint", columnDefinition = "INT(11)", nullable = true)
private Point point;
@ManyToOne
@JoinColumn(name = "idPolygon", columnDefinition = "INT(11)", nullable = true)
private Polygon polygon;
}
答案 0 :(得分:1)
'order'是大多数RDMBS中的受限关键字。尝试“位置”或“排序”。
如果您真的想留在当前名称,可以尝试使用反引号进行定义:
@Column(name = "`order`", columnDefinition = "INT(11)", nullable = false)
private int order;