关于reflection反射的问题!!!

ecaol 2006-06-19 08:38:32
请问下面代码的
record.setId( ( ( Integer )fields.get( "id" ) ).intValue() );
这句是否有意义?
执行update之后并没有返回任何对象类型,
也就是说这个record在这个方法执行过后要被回收,
那么record.setId这个方法我set进去的东西,
在其他地方用clazz.newInstance().getId()

还可以取出来吗?


public static boolean update( Class clazz, Connection conn, HashMap fields ) throws Exception{
SqlStatementInterface state = EnvironmentConfig.getDatabaseState();
ActiveRecord record = ActiveRecord.newInstance( clazz, fields );
if ( true == ( Boolean )fields.get( "isNewRecord" ) ) {
throw new Exception( "[update] isNewRecord is not availiable" );
}
if ( null == fields.get( "id" ) ){
throw new Exception( "[update] id is not availiable" );
} else {
record.setId( ( ( Integer )fields.get( "id" ) ).intValue() );
}
String sql = SqlBuilder.createUpdateOneSql( logger, state, record );
return SqlExecuter.executeUpdate( conn, sql, null );
}
...全文
219 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
congliu 2006-06-19
  • 打赏
  • 举报
回复
不可以
record是局部对象,除非引用到一个数据库的对象,否则离开函数后,此对象会被回收
kingdoom 2006-06-19
  • 打赏
  • 举报
回复
UP

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧