|
|
@@ -50,7 +50,7 @@ public abstract class Model<M extends Model> implements IRow<M>, Serializable {
|
|
|
public static final int FILTER_BY_SAVE = 0;
|
|
|
public static final int FILTER_BY_UPDATE = 1;
|
|
|
|
|
|
- private String configName;
|
|
|
+ String configName;
|
|
|
|
|
|
/**
|
|
|
* Flag of column has been modified. update need this flag
|
|
|
@@ -217,12 +217,21 @@ 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 只允许调用查询方法");
|
|
|
- }
|
|
|
+ // if (attrs == DaoContainerFactory.daoMap) {
|
|
|
+ // throw new RuntimeException("dao 只允许调用查询方法");
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // this.configName = configName;
|
|
|
+ // return (M)this;
|
|
|
|
|
|
- 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);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|