哪个Polygon 类 hibernate可以接受?

Which Polygon classes hibernate can accept?

我有一个 Spring 项目,我正在尝试在 Java 中创建 Hibernate 可以处理的多边形对象,但我已经看到它存在于 Java 许多 class 创建多边形对象,如“org.geojson.Polygon”、“com.vividsolutions.jts.geom.Polygon”或“org.springframework.data.geo.Polygon”。我怎样才能知道 Hibernate 接受了 classes 中的哪一个?

我的 class :



@Entity  public class Area implements Serializable {     

private static final long serialVersionUID = 1L;

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


@Column( columnDefinition = "Polygon" )
private Polygon coordinates;    // What imports to do for this Polygon attribute?


@Column(unique = true)
private String name; 
}

// Constructors and getters/setters ...

感谢您的帮助!

开箱即用的 Hibernate-core 只支持相对有限数量的类型,如果你想使用复杂的类型,比如多边形,你需要自己映射它们(实现 org.hibernate.UserTypeorg.hibernate.CompositeUserType) 或使用为您完成此操作的库。

对于空间数据,有 hibernate-spatial,你会找到一个介绍 here 但基本上你需要添加依赖项:

<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-spatial</artifactId>
    <version>${hibernate.version}</version>
</dependency>