问题描述
这段代码是重写的,transformTuple方法是hibernate会自动调用的对吧?那这样重写后作用是什么?publicObjecttransformTuple(Object[]tuple,String[]aliases){Objectresult=null;try{result=resultClass.newInstance();Method[]methods=resultClass.getMethods();for(Methodmethod:methods){for(inti=0;i<aliases.length;i++){if(tuple[i]==null)continue;if((method.getName().equalsIgnoreCase("set"+aliases[i]))&&(method.getParameterTypes().length==1)){Class<?>cls=method.getParameterTypes()[0];method.invoke(result,this.getObject(cls,tuple[i]));}}}}catch(InstantiationExceptione){thrownewHibernateException("Couldnotinstantiateresultclass:"+resultClass.getName());}catch(IllegalAccessExceptione){thrownewHibernateException("Couldnotinstantiateresultclass:"+resultClass.getName());}catch(IllegalArgumentExceptione){e.printStackTrace();}catch(InvocationTargetExceptione){e.printStackTrace();}returnresult;}