When using Geometry types with Hibernate Spatial and MySQL 5.6+, [the official manual|http://docs.jboss.org/hibernate/orm/5.1/userguide/html_single/Hibernate_User_Guide.html#spatial-configuration-dialect] 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:
{code:java} @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;
// ... } {code}
And I insert a row into the database:
{code:sql} INSERT INTO `beacons` (`name`, ` geo location `) VALUES ('test', ST_GeomFromText('POINT(1.0 2.0)')); {code}
When I try to fetch the row by Hibernate with the dialect {{MySQL56InnoDBSpatialDialect}}, it fails with:
{code} org.hibernate.type.SerializationException: could not deserialize {code} |
|