Solution field and properties that do not match

way1: sql statement from Alias ​​Alias ​​is consistent with the entity class, the name for the field

1 <select id="getOrder2" parameterType="int" resultType="com.zhiyou.clg.bean.Order">
2           select order_id id,order_no no,order_price price from Orders where order_id=#{id}   
3 </select>

way2: Use resultMap tags (attribute: type, id) to define the correspondence between the entity class with fields, comprising label id (primary key) in its label, the label result (the normal field, attributes: column, property)

1 <select id="getOrder" resultMap="myMap">
2            select * from Orders where Order_id=#{id}   
3      </select>
4      <resultMap type="com.zhiyou.clg.bean.Order" id="myMap">
5          <id column="order_id" property="id"/>
6          <result column="order_no" property="no"/>
7          <result column="order_price" property="price"/>
8      </resultMap>    

 

Guess you like

Origin www.cnblogs.com/lwgok1003/p/11442680.html