Hibernate Spatial 5 - GeometryType

后端 未结 6 1879
刺人心
刺人心 2021-02-01 16:36

After upgrading Hibernate-spatial to Version 5.0.0.CR2 the following declaration doesn\'t work anymore:

@Column(columnDefinition = \"geometry(Point,4326)\")
@Typ         


        
6条回答
  •  离开以前
    2021-02-01 16:54

    For Hibernate Spatial 5.2.x, all you need is the below in your entity.

    private Point location;

    You don't need columnDefinition or Type like the above solutions mentioned.

    Some additional details and checks to see if the above works

    • As soon as you run your setup and use desc table_namein mysql, you should see the field type of geometry. This indicates that your hibernate to database mapping is working fine.
    • Now try to create an entity and repo.save(entity) from java and your entity should save fine without any errors.

    If the above setup didn't work well, you will typically get the error

    Data truncation: Cannot get geometry object from data you send to the GEOMETRY field Blockquote

    Hope that helps someone save a 6 hours that I wasted !

提交回复
热议问题