package org.itevents.mapper;

import org.apache.ibatis.annotations.*;
import org.itevents.model.City;
import org.itevents.model.Location;

public interface CityMapper {
    @Results(value = {
            @Result(property = "id", column = "id"),
            @Result(property = "name", column = "name"),
            @Result(property = "location", javaType = Location.class,
                    column = "id", one = @One(select = "org.itevents.mapper.LocationMapper.getCityLocation"))
    })
    @Select("SELECT id, name FROM cities WHERE id = #{id}")
    City getCity(int id);

    @Insert("INSERT INTO cities(id, name, point) VALUES(#{id}, #{name}, #{point}")
    void addCity(City city);

    @Update("UPDATE cities SET id=#{id}, name=#{name}, point=#{point} WHERE id =#{id}")
    void updateCity(City city);

    @Delete("DELETE FROM cities WHERE id =#{id}")
    void removeCity(int id);

}
@@ -618,16 +618,33 @@
  point) 
+%22 +%0A            %22
 VALUES(#
@@ -658,23 +658,70 @@
 %7Bname%7D, 
-#%7Bpoint
+ST_MakePoint(#%7Blocation.longitude%7D,#%7Blocation.latitude
 %7D%22)%0A    
@@ -811,17 +811,81 @@
 int=
-#%7Bpoint%7D 
+ST_MakePoint(#%7Blocation.longitude%7D,#%7Blocation.latitude%7D %22 +%0A            %22
 WHER

fix CityMapper