service方法:
@Aop(TransAop.READ_COMMITTED)
public Object commitDept(NutMap map) throws BusinessException {
NutMap resultMap = new NutMap();
int commitNum = 0;
try{
commitNum = dictServiceBo.commitPublicDict(Ward.class,map);
}catch(Exception e){
throw new BusinessException("提交数据时出错:"+e.getMessage());
}
resultMap.setv("commitNum", commitNum);
return resultMap;
}
工具类方法:
public int commitPublicDict(Class<?> classOfDict,NutMap map){
List<Map> insertList = new ArrayList<Map>();
List<Map> updateList = new ArrayList<Map>();
List<Map> deleteList = new ArrayList<Map>();
insertList = (List)map.get("inserted");
updateList = (List)map.get("updated");
deleteList = (List)map.get("deleted");
int insertNum = 0;
int updateNum = 0;
int deleteNum = 0;
//新增操作
for(int i=0; i<insertList.size(); i++){
//Dept dept = new Dept();
classOfDict = Lang.map2Object(insertList.get(i), classOfDict.getClass());
dao.insert(classOfDict);
insertNum = insertNum + 1;
}
//更新操作
for(int i=0; i<updateList.size(); i++){
//Dept dept = new Dept();
classOfDict = Lang.map2Object(updateList.get(i), classOfDict.getClass());
dao.update(classOfDict);
updateNum = updateNum + 1;
}
//删除操作
for(int i=0; i<deleteList.size(); i++){
//Dept dept = new Dept();
classOfDict = Lang.map2Object(deleteList.get(i), classOfDict.getClass());
dao.delete(classOfDict);
deleteNum = deleteNum + 1;
}
return insertNum + updateNum + deleteNum;
}
报错信息:
For the reason: 提交数据时出错:Fail to born 'java.lang.Class'
by args: [] because: No suitable Constructor or Factory Method!!
at org.nutz.lang.Invoking.invoke(Invoking.java:195)
at org.nutz.lang.Mirror.invoke(Mirror.java:1100)
at com.shlx.blood.service.ComServices.ExcuteServices(ComServices.java:144)
at com.shlx.blood.action.dict.PublicDictAction.commitDept(PublicDictAction.java:121)
at com.shlx.blood.action.dict.PublicDictAction$$FASTCLASS._invoke(PublicDictAction.java:1)
at org.nutz.lang.reflect.AbstractFastClass.invoke(AbstractFastClass.java:143)
at org.nutz.lang.reflect.FastClassFactory.invoke(FastClassFactory.java:67)
at org.nutz.mvc.impl.processor.MethodInvokeProcessor.process(MethodInvokeProcessor.java:27)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.AdaptorProcessor.process(AdaptorProcessor.java:33)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.ActionFiltersProcessor.process(ActionFiltersProcessor.java:58)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.ModuleProcessor.process(ModuleProcessor.java:123)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.EncodingProcessor.process(EncodingProcessor.java:27)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.UpdateRequestAttributesProcessor.process(UpdateRequestAttributesProcessor.java:15)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at com.shlx.blood.mvc.SessionCheckProcessor.process(SessionCheckProcessor.java:56)
at org.nutz.mvc.impl.NutActionChain.doChain(NutActionChain.java:44)
at org.nutz.mvc.impl.ActionInvoker.invoke(ActionInvoker.java:67)
at org.nutz.mvc.ActionHandler.handle(ActionHandler.java:31)
at org.nutz.mvc.NutFilter.doFilter(NutFilter.java:198)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:474)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:624)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:783)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:798)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1434)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Unknown Source)
Caused by: com.shlx.blood.exception.BusinessException: 提交数据时出错:Fail to born 'java.lang.Class'
by args: [] because: No suitable Constructor or Factory Method!!
at com.shlx.blood.service.dict.PublicDictService.commitDept(PublicDictService.java:198)
at com.shlx.blood.service.dict.PublicDictService$$NUTZAOP._aop_invoke(PublicDictService.java:5)
at org.nutz.aop.InterceptorChain.invoke(InterceptorChain.java:77)
at org.nutz.aop.InterceptorChain.doChain(InterceptorChain.java:57)
at org.nutz.aop.interceptor.TransactionInterceptor.filter(TransactionInterceptor.java:34)
at org.nutz.aop.InterceptorChain.doChain(InterceptorChain.java:60)
at com.shlx.blood.aop.ServiceInterceptor.filter(ServiceInterceptor.java:60)
at org.nutz.aop.InterceptorChain.doChain(InterceptorChain.java:60)
at com.shlx.blood.service.dict.PublicDictService$$NUTZAOP.commitDept(PublicDictService.java:1)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.nutz.lang.Invoking$DefaultInvoker.invoke(Invoking.java:47)
at org.nutz.lang.Invoking.invoke(Invoking.java:192)
... 42 more