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

Était-ce utile?

La 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 );
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top