首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Spring data JPA和Geometry类型

Spring data JPA和Geometry类型
EN

Stack Overflow用户
提问于 2016-08-25 21:49:11
回答 1查看 11.9K关注 0票数 7

我正在开发一个将在MySql和MySql上运行的应用程序。

我有一个“几何”类型的空间字段。

通过使用:

代码语言:javascript
复制
 @Column(columnDefinition = "geometry")
 private Point geometry;

(点为org.springframework.data.geo.Point)

Hibernate正确地创建了字段(hbm2ddl)。

但是插入任何点都不起作用。我得到:数据截断:无法从您发送到几何字段的数据中获取几何对象

我使用spring-boot-jpa-starter..而不是直接休眠。

代码语言:javascript
复制
<dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
       <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-spatial</artifactId>
            <version>5.2.2.Final</version>
        </dependency>

致以问候,Ido

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-01-01 10:53:20

您好,我已经成功地在JPA中映射了一个点。下面是我所做的:

  1. 我在Maven上有这个:

com.vividsolutions jts 1.13 org.hibernate hibernate-spatial 5.2.5最终的

  • 我在我的实体上有这个:

@Column( locationpoint;

  • I = "locationpoint",columnDefinition = " Point ")私有点locationpoint;

  • I在我的位置域类spring.jpa.properties.hibernate.dialect=org.hibernate.spatial.dialect.mysql.MySQL56InnoDBSpatialDialect

  • I的application.properties:needed上有以下内容可以使用以下内容获取值:

locationRepository.findOne((long) 1).getLocationpoint().getX();locationRepository.findOne((long) long

我的解决方案基于Matti Tahvonen的例子:

https://github.com/mstahv/spring-boot-spatial-example

希望这能有所帮助。

票数 16
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/39147145

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档