<select id="allSubscribes" resultType="completeCart1">
select a.img, a.name, st.quality, st.outprice, s.number
from subscribe s,
allfood a,
storestock st,
onlineuser o,
store sto
where s.username = o.username
and o.ip = sto.ip
and sto.ownerid = st.ownerid
and s.quality = st.quality
and s.foodid = st.id
and a.id=s.foodid
<if test="username!=null and username!=''">
and s.username=#{username}
</if>
</select>
上面是mybatis中一个查询语句
关于resultType中对象赋值后,对象中某些属性为null的原因是
select出来的column列名与Java对象中的属性名不一致导致的,因为mybatis是根据Java对象中的属性名和select出的列名来赋值的。
解决办法,该查询出的列名或者Java对象属性名让他们要赋值的名字相同就好。