JavaBean:
public class ExpressMessage {
private int id = 0;// 快递单编号
private String sendName = null;// 发件人姓名
private String sendTelephone = null;// 发件人电话
private String sendCompary = null;// 发件人公司
private String sendAddress = null;// 发件人地址
private String sendPostcode = null;// 发送人邮编
private String receiveName = null;// 收件人名称
private String receiveTelephone = null;// 收件人电话
private String receiveCompary = null;// 收件人公司
private String receiveAddress = null;// 收件人地址
private String receivePostcode = null;// 收件人邮编
private String ControlPosition = null; // 快递单上添加信息的组件位置(坐标)
private String expressSize = null; // 快递单的尺寸(大小)
public ExpressMessage() {
super();
}
public ExpressMessage(int id, String sendName, String sendTelephone, String sendCompary, String sendAddress,
String sendPostcode, String receiveName, String receiveTelephone, String receiveCompary,
String receiveAddress, String receivePostcode, String ControlPosition, String expressSize) {
super();
this.id=id;
this.sendName=sendName;
this.sendTelephone=sendTelephone;
this.sendCompary=sendCompary;
this.sendAddress=sendAddress;
this.sendPostcode=sendPostcode;
this.receiveName=receiveName;
this.receiveTelephone=receiveTelephone;
this.receiveCompary=receiveCompary;
this.receiveAddress=receiveAddress;
this.receivePostcode=receivePostcode;
this.ControlPosition=ControlPosition;
this.expressSize=expressSize;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getSendName() {
return sendName;
}
public void setSendName(String sendName) {
this.sendName = sendName;
}
public String getSendTelephone() {
return sendTelephone;
}
public void setSendTelephone(String sendTelephone) {
this.sendTelephone = sendTelephone;
}
public String getSendCompary() {
return sendCompary;
}
public void setSendCompary(String sendCompary) {
this.sendCompary = sendCompary;
}
public String getSendAddress() {
return sendAddress;
}
public void setSendAddress(String sendAddress) {
this.sendAddress = sendAddress;
}
public String getSendPostcode() {
return sendPostcode;
}
public void setSendPostcode(String sendPostcode) {
this.sendPostcode = sendPostcode;
}
public String getReceiveName() {
return receiveName;
}
public void setReceiveName(String receiveName) {
this.receiveName = receiveName;
}
public String getReceiveTelephone() {
return receiveTelephone;
}
public void setReceiveTelephone(String recieveTelephone) {
this.receiveTelephone = recieveTelephone;
}
public String getReceiveCompary() {
return receiveCompary;
}
public void setReceiveCompary(String recieveCompary) {
this.receiveCompary = recieveCompary;
}
public String getReceiveAddress() {
return receiveAddress;
}
public void setReceiveAddress(String receiveAddress) {
this.receiveAddress = receiveAddress;
}
public String getReceivePostcode() {
return receivePostcode;
}
public void setReceivePostcode(String receivePostcode) {
this.receivePostcode = receivePostcode;
}
public String getControlPosition() {
return ControlPosition;
}
public void setControlPosition(String controlPosition) {
ControlPosition = controlPosition;
}
public String getExpressSize() {
return expressSize;
}
public void setExpressSize(String expressSize) {
this.expressSize = expressSize;
}
@Override
public String toString() {
return "ExpressMessaage [id=" + id + ", sendName=" + sendName + ", sendTelephone=" + sendTelephone + "]";
}
}
EmployeeMapper:
public Vector<ExpressMessage> queryAllExpress();//这个是重点,返回值一定要写好!!!
EmployeeMapper.xml
<select id="queryAllExpress" resultType="com.zzk.bean.ExpressMessage">
select
id,sendName,sendTelephone,sendCompary,sendAddress,sendPostcode,receiveName,recieveTelephone,recieveCompary,receiveAddress,receivePostcode,ControlPosition,expressSize
from tb_receiveSendMessage
</select>
应用:
public SqlSessionFactory getSqlSessionFactory() throws IOException {
String resource = "mybatis-config.xml";
InputStream inputStream = Resources.getResourceAsStream(resource);
return new SqlSessionFactoryBuilder().build(inputStream);
}
public Vector queryAllExpress() throws IOException {
SqlSessionFactory sqlSessionFactory = getSqlSessionFactory();
// 1、获取到的SqlSession不会自动提交数据
SqlSession openSession = sqlSessionFactory.openSession();
try {
EmployeeMapper mapper = openSession.getMapper(EmployeeMapper.class);
// Vector<ExpressMessage> v = new Vector<ExpressMessage>();// 创建动态数组
ExpressMessage m = new ExpressMessage();
Vector<ExpressMessage> v = mapper.queryAllExpress();
System.out.println(v);
// System.out.println(employee);
return v;
} finally {
openSession.close();
}
}