diff --git a/mybatis-plus/pom.xml b/mybatis-plus/pom.xml
index 8b5c3b8071..e61786d6b4 100644
--- a/mybatis-plus/pom.xml
+++ b/mybatis-plus/pom.xml
@@ -3,7 +3,7 @@
4.0.0
com.baomidou
mybatis-plus
- 2.0-rc
+ 2.0
jar
mybatis-plus
diff --git a/mybatis-plus/src/main/java/com/baomidou/mybatisplus/activerecord/Model.java b/mybatis-plus/src/main/java/com/baomidou/mybatisplus/activerecord/Model.java
index 810de74c5b..8ae7904e30 100644
--- a/mybatis-plus/src/main/java/com/baomidou/mybatisplus/activerecord/Model.java
+++ b/mybatis-plus/src/main/java/com/baomidou/mybatisplus/activerecord/Model.java
@@ -15,6 +15,15 @@
*/
package com.baomidou.mybatisplus.activerecord;
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.ibatis.logging.Log;
+import org.apache.ibatis.logging.LogFactory;
+import org.apache.ibatis.session.SqlSession;
+
import com.baomidou.mybatisplus.enums.SqlMethod;
import com.baomidou.mybatisplus.exceptions.MybatisPlusException;
import com.baomidou.mybatisplus.mapper.Condition;
@@ -24,14 +33,6 @@
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.toolkit.StringUtils;
-import org.apache.ibatis.logging.Log;
-import org.apache.ibatis.logging.LogFactory;
-import org.apache.ibatis.session.SqlSession;
-
-import java.io.Serializable;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
/**
*
@@ -92,6 +93,9 @@ public boolean deleteById(Serializable id) {
* @return
*/
public boolean deleteById() {
+ if (null == this.pkVal()) {
+ throw new MybatisPlusException("deleteById primaryKey is null.");
+ }
return deleteById(this.pkVal());
}
@@ -134,7 +138,7 @@ public boolean delete(Wrapper wrapper) {
*/
public boolean updateById() {
if (null == this.pkVal()) {
- throw new MybatisPlusException("primaryKey is null.");
+ throw new MybatisPlusException("updateById primaryKey is null.");
}
// updateById
return SqlHelper.retBool(sqlSession().update(sqlStatement(SqlMethod.UPDATE_BY_ID), this));
@@ -204,6 +208,9 @@ public T selectById(Serializable id) {
* @return
*/
public T selectById() {
+ if (null == this.pkVal()) {
+ throw new MybatisPlusException("selectById primaryKey is null.");
+ }
return selectById(this.pkVal());
}
diff --git a/mybatis-plus/src/main/java/com/baomidou/mybatisplus/mapper/SqlQuery.java b/mybatis-plus/src/main/java/com/baomidou/mybatisplus/mapper/SqlQuery.java
index 05ca728766..576539589e 100644
--- a/mybatis-plus/src/main/java/com/baomidou/mybatisplus/mapper/SqlQuery.java
+++ b/mybatis-plus/src/main/java/com/baomidou/mybatisplus/mapper/SqlQuery.java
@@ -15,24 +15,25 @@
*/
package com.baomidou.mybatisplus.mapper;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.ibatis.logging.Log;
+import org.apache.ibatis.logging.LogFactory;
+import org.apache.ibatis.session.SqlSession;
+import org.apache.ibatis.session.SqlSessionFactory;
+
import com.baomidou.mybatisplus.entity.GlobalConfiguration;
import com.baomidou.mybatisplus.entity.TableInfo;
import com.baomidou.mybatisplus.plugins.pagination.Pagination;
import com.baomidou.mybatisplus.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.toolkit.StringUtils;
import com.baomidou.mybatisplus.toolkit.TableInfoHelper;
-import org.apache.ibatis.logging.Log;
-import org.apache.ibatis.logging.LogFactory;
-import org.apache.ibatis.session.SqlSession;
-import org.apache.ibatis.session.SqlSessionFactory;
-
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
/**
*
- * SQLQuery直接执行SQL
+ * SqlQuery 执行 SQL
*
*
* @author Caratacus
@@ -41,7 +42,7 @@
public class SqlQuery {
private static final Log logger = LogFactory.getLog(SqlQuery.class);
// 单例Query
- public static final SqlQuery query = new SqlQuery();
+ public static final SqlQuery SQL_QUERY = new SqlQuery();
private SqlSessionFactory sqlSessionFactory;
private TableInfo tableInfo;
@@ -54,8 +55,7 @@ public SqlQuery() {
public SqlQuery(Class> clazz) {
this.tableInfo = SqlHelper.table(clazz);
- String configMark = tableInfo.getConfigMark();
- GlobalConfiguration globalConfiguration = GlobalConfiguration.GlobalConfig(configMark);
+ GlobalConfiguration globalConfiguration = GlobalConfiguration.GlobalConfig(tableInfo.getConfigMark());
this.sqlSessionFactory = globalConfiguration.getSqlSessionFactory();
}
@@ -104,7 +104,7 @@ public List