From 1fa4cec10b4b29c622a89e7f94f4e5269fd644a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Fri, 24 Mar 2017 12:04:14 +0100 Subject: java : MyMyBatis : minor cleanups --- java/MyMyBatis/src/ModelMapper.java | 10 +++++----- java/MyMyBatis/src/SqlConnection.java | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/java/MyMyBatis/src/ModelMapper.java b/java/MyMyBatis/src/ModelMapper.java index 6eb566c..77b1921 100644 --- a/java/MyMyBatis/src/ModelMapper.java +++ b/java/MyMyBatis/src/ModelMapper.java @@ -10,9 +10,9 @@ import org.apache.ibatis.annotations.Select; public interface ModelMapper extends AbstractMapper { final static String attrs = " id, name "; + final static String from = " from models "; final static String where = " where id=#{id} "; - final static String INSERT = "insert into models(name) values (#{name})"; @Insert(INSERT) int insert(Model obj); @@ -21,19 +21,19 @@ public interface ModelMapper extends AbstractMapper @Update(UPDATE) int update(Model obj); - final static String DELETE = "delete from models" + where; + final static String DELETE = "delete" + from + where; @Delete(DELETE) int delete(Model obj); - final static String COUNT = "select count(*) from models"; + final static String COUNT = "select count(*)" + from; @Select(COUNT) int count(); - final static String SELECT = "select" + attrs + "from models"; + final static String SELECT = "select" + attrs + from; @Select(SELECT) List select(); - final static String SELECT_ONE = "select" + attrs + "from models" + where; + final static String SELECT_ONE = SELECT + where; @Select(SELECT_ONE) Model selectOne(Integer id); } diff --git a/java/MyMyBatis/src/SqlConnection.java b/java/MyMyBatis/src/SqlConnection.java index 57f2ea5..2382e2e 100644 --- a/java/MyMyBatis/src/SqlConnection.java +++ b/java/MyMyBatis/src/SqlConnection.java @@ -27,7 +27,7 @@ public class SqlConnection public SqlConnection() { - this.logger = logger = LoggerFactory.getLogger(Main.class); + this.logger = LoggerFactory.getLogger(this.getClass()); PooledDataSource ds = new PooledDataSource("org.hsqldb.jdbcDriver", "jdbc:hsqldb:mem:test;sql.syntax_pgs=true;check_props=true", "username", "password"); ds.setDefaultAutoCommit(false); // ds.setPoolMaximumActiveConnections(); -- cgit v1.1-2-g2b99