Browse Source

use(configName)改回在dao()后不允许调用,因为有用户使用该方法之后再调dao()永久configName切换

James 3 years ago
parent
commit
76ed043602
1 changed files with 5 additions and 14 deletions
  1. 5 14
      src/main/java/com/jfinal/plugin/activerecord/Model.java

+ 5 - 14
src/main/java/com/jfinal/plugin/activerecord/Model.java

@@ -217,21 +217,12 @@ public abstract class Model<M extends Model> implements IRow<M>, Serializable {
 	 * Switching data source, dialect and all config by configName
 	 */
 	public M use(String configName) {
-		// if (attrs == DaoContainerFactory.daoMap) {
-		// 	throw new RuntimeException("dao 只允许调用查询方法");
-		// }
-		//
-		// this.configName = configName;
-		// return (M)this;
-
-		try {
-			// 支持 dao().use(configName)
-			M ret = (M) _getUsefulClass().newInstance();
-			ret.configName = configName;
-			return ret;
-		} catch (ReflectiveOperationException e) {
-			throw new RuntimeException(e);
+		if (attrs == DaoContainerFactory.daoMap) {
+			throw new RuntimeException("dao 只允许调用查询方法");
 		}
+
+		this.configName = configName;
+		return (M)this;
 	}
 
 	/**