0
我在MyBatis網站中創建一個具有嵌套集合的映射器,當我執行select操作時,我的對象(Provider)返回,但其中的集合( ProviderParameter)是空的,當我轉到數據庫工具並應用相同的查詢時,我得到預期的結果(集合也返回)。MyBatis,集合的嵌套結果爲空
這裏是我的映射:
<resultMap id="Provider" type="xxx.Provider">
<result column="idProvider" property="idProvider"/>
<result column="providerType" property="providerType"/>
<result column="username" property="username"/>
<result column="password" property="password"/>
<result column="licenceInformation" property="licenseInformation"/>
<collection property="parameters" ofType="xxx.ProviderParameter">
<result column="idProviderParameter" property="idProviderParameter"/>
<result column="name" property="name"/>
<result column="value" property="value"/>
</collection>
</resultMap>
和選擇:
<select id="getProviderById" resultType="xxx.Provider">
select P.idProvider as idProvider
,P.providerType as providerType
,P.username as username
,P.password as password
,P.licenceInformation as licenceInformation
,PP.idProviderParameter as idProviderParameter
,PP.name as name
,PP.value as value
from [dbo].[msg_Provider] AS P
left outer join [dbo].[msg_ProviderParameter] AS PP on P.idProvider = PP.idProvider
where P.idProvider = #{idProvider}
</select>