关于reflection反射的问题!!!
请问下面代码的
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 );
}
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 );
}
...全文
相关推荐
Unity Planar Reflection平面反射
Unity Planar Reflection平面反射
详解C# 反射(Reflection)
性能问题:反射操作相比直接的代码执行通常较慢,因为它涉及到运行时的元数据解析和类型查找。因此,在性能敏感的代码中应谨慎使用。2.
C#反射(Reflection)详解
C#反射(Reflection)详解什么是反射命名空间和装配体的关系
C# 反射(Reflection)的用处分析
在C#编程中,反射(Reflection)是一种强大的工具,它允许程序在运行时检查和操作自身,包括类、接口、属性、方法等元数据。反射的主要用途在于动态类型创建、运行时成员访问以及元数据的读取。
反射Reflection小应用
在Java编程语言中,反射(Reflection)是一种强大的工具,它允许程序在运行时检查和操作类、接口、字段和方法的信息。


Java SE

