2 qq 39380645 qq_39380645 于 2017.08.29 22:13 提问

如何通过MyBits获取数据库的值

public List getByWgCgPurchaseId(String id) {
//使用Mybatis读取数据库
List wgCgPurchaseEntryList = new ArrayList();
/*for(int i=0;i<=1;i++) {
WgCgPurchaseEntry wgCgPurchaseEntry = new WgCgPurchaseEntry();
wgCgPurchaseEntry.setId("902093569836187648"+i);
wgCgPurchaseEntry.setWgPurchaseId("902093569492254720");
wgCgPurchaseEntry.setWgMaterialId("901990015158976512");
wgCgPurchaseEntry.setWgMaterialCode("01.09");
wgCgPurchaseEntry.setWgMaterialName("111");
wgCgPurchaseEntryList.add(wgCgPurchaseEntry);
}*/
return wgCgPurchaseEntryList;
}
这种是手动赋值,怎么才能获取到数据库的值????

2个回答

pansanday
pansanday   2017.08.30 10:54

xxxMapper.java
public interface xxxMapper {
public List getByWgCgPurchaseId(@Param(value="id") String id);
}

xxxMapper.xml

select * from xxxx where id=#{id};

pansanday
pansanday   2017.08.30 10:54
 xxxMapper.java
public interface xxxMapper {
    public List getByWgCgPurchaseId(@Param(value="id") String id);
}

xxxMapper.xml
<select id="getByWgCgPurchaseId" resultMap="WgCgPurchaseEntry">
    select * from xxxx where id=#{id};
</select>
Csdn user default icon
上传中...
上传图片
插入图片