type error 1009-無法存取Null 物件參考的屬性或方法

昨天做一个绘图class,做成文档类可以,直接在时间轴裏写var myClass:ClassA=new Class();就是不行。FLASH 报出“type error 1009-無法存取Null 物件參考的屬性或方法”。查了一下,class裏引用了Stage的属性,而Stage在没有被添加到displayObject之前,是Null的,这样就报错了。
需要用到这个事件来触发:Event.ADDED_TO_STAGE,调用函数init()。
if (stage) {
                init();
            } else {
                addEventListener(Event.ADDED_TO_STAGE, init);
               
            }

        }
        public function init(e:Event=null):void {
            removeEventListener(Event.ADDED_TO_STAGE, init);
            trace("init"+stage);
......
Event.ADDED_TO_STAGE only gets dispatched once an object has been added to a displayList, and also all its parents have been added. If it is already there, it won't fire again.
在MyBatis-Plus中,`configuration.jdbc-type-for-null` 是一个重要的配置项,主要用于处理SQL参数为 `null` 时的 `JdbcType` 类型。 ### 作用 在MyBatis与数据库交互过程中,当SQL语句的参数为 `null` 时,需要指定一个 `JdbcType` 类型。不同的数据库对于 `null` 值的处理方式有所不同,默认情况下MyBatis-Plus使用 `JdbcType.OTHER`。然而,某些数据库(如Oracle)可能不支持 `JdbcType.OTHER`,在插入更新 `null` 值时会报错,例如出现 `Error setting null for parameter # with JdbcType OTHER` 的异常。通过配置 `configuration.jdbc-type-for-null`,可以指定当参数为 `null` 时使用的 `JdbcType`,从而避免此类错误 [^1][^3]。 ### 配置方式 #### Java代码配置 可以通过自定义 `ConfigurationCustomizer` 来配置 `jdbcTypeForNull`。示例代码如下: ```java import org.apache.ibatis.session.Configuration; import org.apache.ibatis.type.JdbcType; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import com.baomidou.mybatisplus.extension.plugins.MybatisPlusCustomizers; @Configuration public class MyBatisPlusConfig { @Bean public ConfigurationCustomizer configurationCustomizer() { return new MybatisPlusCustomizers() { @Override public void customize(Configuration configuration) { configuration.setJdbcTypeForNull(JdbcType.NULL); } }; } } ``` 上述代码中,通过创建一个 `ConfigurationCustomizer` 实例,并重写 `customize` 方法,将 `jdbcTypeForNull` 设置为 `JdbcType.NULL`,以适应Oracle数据库的需求 [^1]。 #### YAML配置 如果使用YAML配置文件,也可以直接在 `mybatis-plus` 配置下设置 `jdbc-type-for-null`。示例如下: ```yaml mybatis-plus: configuration: jdbc-type-for-null: NULL ``` 这种方式更加简洁,直接在配置文件中指定 `jdbc-type-for-null` 的值为 `NULL`。 ### 使用场景 当项目使用的数据库(如Oracle)对 `null` 值的 `JdbcType` 有特殊要求时,就需要配置 `configuration.jdbc-type-for-null`。在开发过程中,如果遇到插入更新 `null` 值时出现 `JdbcType` 相关的错误,可通过配置该属性解决问题 [^3]。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值