Mysql 在hibernate注释中设置srid

Mysql 在hibernate注释中设置srid,mysql,hibernate,spring-boot,Mysql,Hibernate,Spring Boot,我使用SpringBoot2.1、hibernate和mysql 8处理gis项目 我有一张有这个细节的桌子 @Data @Entity @EntityListeners(AuditingEntityListener.class) public class Place { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) Long Id; @Column(nullable = false, colu

我使用SpringBoot2.1、hibernate和mysql 8处理gis项目

我有一张有这个细节的桌子

@Data
@Entity
@EntityListeners(AuditingEntityListener.class)
public class Place {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    Long Id;

    @Column(nullable = false, columnDefinition = "point")
    Point point;

    String tittle;
    String text;

    @Column(name = "created_date", nullable = false, updatable = false)
    @CreatedDate
    @JsonIgnore
    private long createdDate;

    @Column(name = "modified_date")
    @LastModifiedDate
    @JsonIgnore
    private long modifiedDate;

    @org.springframework.data.annotation.CreatedBy
    @JsonIgnore
    Long CreatedBy;

    @LastModifiedBy
    @JsonIgnore
    Long ModifiedBy;

    @ManyToOne(fetch=FetchType.LAZY,optional = false)
    @JoinColumn(name="city_id",nullable = false)
    @OnDelete(action = OnDeleteAction.CASCADE)
    private City city;
}
我想为点添加索引,但mysql向我发出警告:

查询优化器不会使用列“point”上的空间索引,因为该列没有SRID属性。考虑向列中添加SRID属性。

如何将srid属性添加到带注释的点,以及如何将空间索引添加到带注释的点。

使用列定义进行尝试。使用Hibernate 5.4.2和MySQL 8.0进行测试

@Entity
public class GeometryEntity {

  @Id
  @GeneratedValue
  private Long id;

  // only allow geometries with SRID 4326 and not null (be able to create spatial indexes)
  @Column(nullable = false, columnDefinition = "GEOMETRY SRID 4326")
  private Geometry geometry;

  private void setId(final Long id) {
    this.id = id;
  }

  public Long getId() {
    return id;
  }

  public void setGeometry(final Geometry geometry) {
    this.geometry = geometry;
  }

  public Geometry getGeometry() {
    return geometry;
  }

}
另见: