We're updating the issue view to help you get more done. 

MySQL56SpatialDialect does not register geometry types causing Geometry types are not correctly deserialized

Description

When using Geometry types with Hibernate Spatial and MySQL 5.6+, the official manual recommends using MySQL56SpatialDialect and MySQL56InnoDBSpatialDialect (there are some typos in the manual).

However, when using either of the two classes as the dialect of Hibernate, Hibernate will fail to choose the correct serializer to parse the binary Geometry data. In fact, the associations between the SQL geometry type and the corresponding are not registered at all, which should be done in contributeTypes method. These two classes has not overridden this method yet.

Here is an example of this situation:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 @Entity @Table(name = "beacons") public class Beacon implements Serializable { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Integer id; @Column(nullable = false) private String name; private Point location; // ... }

And I insert a row into the database:

1 INSERT INTO `beacons` (`name`, `location`) VALUES ('test', ST_GeomFromText('POINT(1.0 2.0)'));

When I try to fetch the row by Hibernate with the dialect MySQL56InnoDBSpatialDialect, it fails with:

1 org.hibernate.type.SerializationException: could not deserialize

Environment

Hibernate 5.1.0 with hibernate-java8 and hibernate-spatial
Database: MySQL 5.6.21 under Windows (32 bit)

Status

Assignee

Unassigned

Reporter

Kevin Han

Fix versions

Labels

None

backPortable

None

Suitable for new contributors

Yes, likely

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

5.2.2
5.2.0
5.1.0
5.1.1
5.2.1

Priority

Major