MySQL的ResultMap如何映照NULL值
在MySQL中,如果查询结果中有NULL值,ResultMap可使用jdbcType="NULL"
来映照NULL值。示例以下:
<resultMap id="userResultMap" type="User">
<result column="id" property="id" jdbcType="INTEGER"/>
<result column="username" property="username" jdbcType="VARCHAR"/>
<result column="email" property="email" jdbcType="VARCHAR"/>
<result column="age" property="age" jdbcType="INTEGER"/>
</resultMap>
在上面的示例中,如果查询结果中的age
字段为NULL,那末会将NULL值映照到User
对象的age
属性上。
tiktok粉丝购买:https://www.smmfensi.com/
TOP