diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2017-03-23 17:10:39 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2017-03-23 17:10:39 +0100 |
commit | 724efad67fe61d2c02c41af24ebc352eb79ff2f8 (patch) | |
tree | 777e62835ca2f6901d8d2542e328fcea403f9680 /java/MyMyBatis/src/ModelMapper.java | |
parent | bb1caf716a18b65fa42d7bed2369b66a0837d977 (diff) | |
download | share-724efad67fe61d2c02c41af24ebc352eb79ff2f8.zip share-724efad67fe61d2c02c41af24ebc352eb79ff2f8.tar.gz |
java : add MyMyBatis
Diffstat (limited to 'java/MyMyBatis/src/ModelMapper.java')
-rw-r--r-- | java/MyMyBatis/src/ModelMapper.java | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/java/MyMyBatis/src/ModelMapper.java b/java/MyMyBatis/src/ModelMapper.java new file mode 100644 index 0000000..6eb566c --- /dev/null +++ b/java/MyMyBatis/src/ModelMapper.java @@ -0,0 +1,39 @@ +package ch.asynk; + +import java.util.List; + +import org.apache.ibatis.annotations.Insert; +import org.apache.ibatis.annotations.Delete; +import org.apache.ibatis.annotations.Update; +import org.apache.ibatis.annotations.Select; + +public interface ModelMapper extends AbstractMapper<Model, Integer> +{ + final static String attrs = " id, name "; + final static String where = " where id=#{id} "; + + + final static String INSERT = "insert into models(name) values (#{name})"; + @Insert(INSERT) + int insert(Model obj); + + final static String UPDATE = "update models set name=#{name}" + where; + @Update(UPDATE) + int update(Model obj); + + final static String DELETE = "delete from models" + where; + @Delete(DELETE) + int delete(Model obj); + + final static String COUNT = "select count(*) from models"; + @Select(COUNT) + int count(); + + final static String SELECT = "select" + attrs + "from models"; + @Select(SELECT) + List<Model> select(); + + final static String SELECT_ONE = "select" + attrs + "from models" + where; + @Select(SELECT_ONE) + Model selectOne(Integer id); +} |