在goods.xml文件中增加
<select id="selectGoodsMap" resultType="java.util.LinkedHashMap">
select g.*, c.cateName from t_goods g, t_category c
where g.category_Id = c.category_Id
</select>
@Test
public void testSelectGoodsMap() throws Exception {
SqlSession session = null;
try{
session = MyBatisUtils.openSession();
List<Map> g = session.selectList("goods.selectGoodsMap");
for(Map f: g){
System.out.println(f);
}
}catch(Exception e){
throw e;
}finally{
MyBatisUtils.closeSession(session);
}
}
结果
{goods_Id=1, title=亲润 孕妇护肤品豆乳大米莹润保湿胶, sub_title=卓效对抗孕期干燥,15分钟快速补水, original_cost=399.0, current_price=258.0, discount=0.65, is_free_delivery=1, category_Id=1, cateName=护肤品}
{goods_Id=2, title=爱恩幼 孕妇护肤品润颜睡眠面膜, sub_title=免洗配方,质地清透不粘腻,睡眠间为肌肤深层护肤, original_cost=455.0, current_price=398.0, discount=0.87, is_free_delivery=1, category_Id=1, cateName=护肤品}
{goods_Id=3, title=私利安 孕妈专用 洗发水 氨基酸表面, sub_title=含叶酸 无硅油 深层锁水 天然成分, original_cost=233.0, current_price=200.0, discount=0.86, is_free_delivery=1, category_Id=2, cateName=洗发水}
{goods_Id=4, title=亲恩 孕妇护肤品 燕窝补水保湿6件套, sub_title=买一送11, 价值129元大礼包, 萃取深层芦荟, original_cost=300.0, current_price=278.0, discount=0.93, is_free_delivery=1, category_Id=1, cateName=护肤品}
{goods_Id=5, title=优美育 补水保湿 黄金水润嫩肤三件套, sub_title=孕妇护肤品,黄金果三件套(中样装), original_cost=400.0, current_price=350.0, discount=0.88, is_free_delivery=1, category_Id=1, cateName=护肤品}
{goods_Id=6, title=雅姿美特 孕妇护肤品天然叶酸, sub_title=为孕期肌肤补充所需营养, original_cost=500.0, current_price=420.0, discount=0.84, is_free_delivery=0, category_Id=1, cateName=护肤品}
{goods_Id=7, title=亲润 孕妇专用遮瑕宝石隔离霜提亮肤色, sub_title=美颜小墨盒,3秒贴装,8小时定妆, original_cost=299.0, current_price=250.0, discount=0.84, is_free_delivery=0, category_Id=3, cateName=隔离霜}
{goods_Id=8, title=美康粉黛 金风玉露隔离霜孕妇护肤品, sub_title=天然植物彩妆,孕妈妆前乳隔离霜, original_cost=333.0, current_price=289.0, discount=0.87, is_free_delivery=0, category_Id=3, cateName=隔离霜}
本文地址:https://blog.csdn.net/mercies/article/details/110727726