在mybatis中使用级连查询时,有个地方需要注意:
- 一对一:association
映射类型指定时使用javaType
<association property="businessInfo" select="com.easyaccount.dao.BusinessInfoMapper.selectByBillId"
column="bill_id" javaType="com.easyaccount.model.BusinessInfo"></association>
- 一对多:collection
映射类型指定时使用ofType,倘若这里不小心写成javaType,那么就会出现如标题中的错误
<collection property="traffics" select="com.easyaccount.dao.TrafficMapper.selectByBillId"
column="bill_id" ofType="com.easyaccount.model.Traffic"></collection>