@SuppressWarnings("unchecked") public static final T injectModel(Class modelClass, String modelName, HttpServletRequest request, boolean skipConvertError) { Object temp = createInstance(modelClass); if (temp instanceof Model == false) { throw new IllegalArgumentException("getModel only support class of Model, using getBean for other class."); }
Model model = (Model)temp; Table table = TableMapping.me().getTable(model.getClass()); if (table == null) { throw new ActiveRecordException("The Table mapping of model: " + modelClass.getName() + " not exists or the ActiveRecordPlugin not start."); }
Class colType = table.getColumnType(attrName); if (colType == null) { if (skipConvertError) { continue ; } else { throw new ActiveRecordException("The model attribute " + attrName + " is not exists."); } }
根据业务去做这些功能没有什么隐患,希望你搞定以后可以回社区分享给大家,感谢反馈