MyBatis Type Handlers for PostGIS

Build Status Maven central

The MyBatis type handlers supporting geometry types introduced in PostGIS: JDBC Geometry API


Java 7 or higher.

The latest PostGIS JDBC API which it depends on was using the JRE7 version of PostgreSQL JDBC, so it requires Java 7 or higher.


If you are using Maven add the following dependency to your pom.xml:



    <!-- ... -->
    <typeHandler handler="com.eyougo.mybatis.postgis.type.PointTypeHandler" />
    <typeHandler handler="com.eyougo.mybatis.postgis.type.PolygonTypeHandler" />

With XML Configuration

<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
    <!-- ... -->
    <property name="typeAliasesPackage" value="com.eyougo.mybatis.postgis.type" />

Or with Java configuration

public SqlSessionFactory sqlSessionFactory(Configuration config) {
    SqlSessionFactoryBean factory = new SqlSessionFactoryBean();
    // ...
    return factory.getObject();

mybatis.type-handlers-package = com.eyougo.mybatis.postgis.type

Or application.yml

    type-handlers-package: com.eyougo.mybatis.postgis.type

Supported types

The following type handlers are supported:

Type handler PostGIS Geometry API type Available version
PointTypeHandler org.postgis.Point 1.0
PolygonTypeHandler org.postgis.Polygon 1.0
LineStringTypeHandler org.postgis.LineString 1.0
MultiPointTypeHandler org.postgis.MultiPoint 1.0

Note: For more details of type handler, please refer to "MyBatis 3 REFERENCE DOCUMENTATION".