Question

I'm using mybatis in my project and I need to insert data on a column of type "point" (mysql).

How can I do it?

I've managed to create a mapper for my table but how can I specify the geometry data type for the query?

Thanks

Was it helpful?

Solution

The mysql statement for Point column is

INSERT INTO t1 (pt_col) VALUES(Point(1,2))

Thus you can just pass in the values accordingly in Mybatis?

A basic example will be like

@Insert( "INSERT INTO t1( pt_col ) values( Point( #{x}, #{y} )" )
public int insert( @Param("x") int x, @Param("y") int y );
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top