Liquibase generate migration for geometry type (Spring boot with JPA/Hibernate)


I am writing a RESTfull API with Spring boot using Maven Liquibase to manage migrations alongside MySQL 8 for the database.

I have searched online (1,2, 3) but Liquibase is still generating "TINYBLOB" type in migrations instead of "POINT" or "GEOMETRY". Surprisingly, when I edit the migration file (i.e. changeSet and use "POINT", mvn liquibase:update still creates a TINYBLOB column on the database.

I have a typal JPA entity:

import org.locationtech.jts.geom.Point;

class MyModel {

  private Point location;

  // more fields

I am using Liquibase version 4.3 and Hibernate version 5.4. For hibernate dialect, I am using org.hibernate.spatial.dialect.mysql.MySQL8SpatialDialect.

It appears to me that spatial types are not supposed by Liquibase… but that would be surprising. Any help would be greatly appreciated (all other data types are behaving as expected).


Ran into the same issue some time ago and ended up manually overwriting parts of the auto-generated migration file. Worked fine for MySQL 8.

 <!--    Define the type-->
<property name="pointType" value="geometry" dbms="h2"/> <!--    Only relevant for in-memory integration tests-->
<property name="pointType" value="POINT" dbms="mysql, oracle, mssql, mariadb, postgresql"/>

<!--    Use the type on the column-->
<column name="location" type="${pointType}">
    <constraints nullable="true" />

A simplified version of my Hibernate model.

package com.stackoverflow.sample.domain;

import com.vividsolutions.jts.geom.Point;
import org.hibernate.annotations.Type;

import javax.persistence.*;

@Table(name = "some_entity")
public class SomeEntity implements Serializable {

    private static final long serialVersionUID = 1L;

    @GeneratedValue(strategy = GenerationType.IDENTITY) = FieldType.Keyword)
    private Long id;

    @Type(type = "com.vividsolutions.jts.geom.Point")
    @Column(name = "location", nullable = false, columnDefinition = "geometry")
    private Point location;


Answered By – bahizi

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published