Uploaded image for project: 'Hibernate ORM'
  1. HHH-11087

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


    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects versions: 5.1.0, 5.2.0, 5.2.1, 5.2.2, 5.1.1
    • Fix versions: 5.2.4, 5.1.3, 5.0.12
    • Components: hibernate-spatial
    • Labels:
    • Environment:
      Hibernate 5.1.0 with hibernate-java8 and hibernate-spatial
      Database: MySQL 5.6.21 under Windows (32 bit)
    • Bug Testcase Reminder (view):

      Bug reports should generally be accompanied by a test case!

    • Suitable for new contributors:
      Yes, likely
    • Last commented by a user?:
    • Sprint:


      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:

      @Table(name = "beacons")
      public class Beacon implements Serializable {
          @GeneratedValue(strategy = GenerationType.IDENTITY)
          private Integer id;
          @Column(nullable = false)
          private String name;
          private Point location;
          // ...

      And I insert a row into the database:

      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:

      org.hibernate.type.SerializationException: could not deserialize




            • Votes:
              1 Vote for this issue
              2 Start watching this issue


              • Created: