【发布时间】:2018-06-05 13:56:14
【问题描述】:
我想使用关系表上的附加参数和不同的主键创建 JPA 关系 ManyToMany,但我仍然收到以下错误:有人可以帮我吗?谢谢
您的 SQL 语法有错误;检查手册 对应于您的 MariaDB 服务器版本,以便使用正确的语法 'order 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;
}
【问题讨论】:
标签: java spring spring-boot jpa mariadb