返回的对象不为null,但是属性值为null
代码如下:
<resultMap id="BaseResultMap" type="com.xxx.xxx.dao.model.MerchantUser">
<id column="MU_ID" jdbcType="BIGINT" property="muId"/>
<result column="USER_ID" jdbcType="BIGINT" property="userId"/>
<result column="MERCHANT_NO" jdbcType="VARCHAR" property="merchantNo"/>
<result column="USER_PHONE" jdbcType="VARCHAR" property="userPhone"/>
<result column="GRANTED" jdbcType="VARCHAR" property="granted"/>
<result column="CREATE_DATE" jdbcType="TIMESTAMP" property="createDate"/>
<result column="MERCHANT_USER_ID" jdbcType="VARCHAR" property="merchantUserId"/>
<result column="STATUS" jdbcType="VARCHAR" property="status"/>
<result column="ENTE_USER_NO" jdbcType="VARCHAR" property="enteUserNo"></result>
</resultMap>
<sql id="Base_Column_List">
MU_ID muId,
USER_ID userId,
MERCHANT_NO merchantNo,
USER_PHONE userPhone,
GRANTED granted,
CREATE_DATE createDate,
MERCHANT_USER_ID merchantUserId,
ENTE_USER_NO enteUserNo,
STATUS status
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from merchant_user
where MU_ID = #{muId,jdbcType=BIGINT}
</select>
原因分析:
如果返回的对象是resultMap 那么就不要给字段加别名了,问题就是出在这里,将字段别名去了就OK;
如果要给字段加别名,那么你就直接返回该对象就好了,路径要写全,如:resultType="com.trhui.ebook.dao.model.MerchantUser"
而不是返回resultMap="BaseResultMap"
来源:CSDN
作者:有梦青年
链接:https://blog.csdn.net/qq_32814555/article/details/104169962