如何写选择标签formsmybatis选择
如果我有课
public class Product { private int id; private String name; private double price; private String type; }
一个dao界面
public interface { public Product selectOne(int id); }
数据库中的表
T_Product ( id tinyint, name varchar(50), price long, type varchar(30) );
我想知道如何在mybatis中为selectOne方法编写sqlMapper!
这是注释的另一个选项:
public interface ProductMapper{ @Select( "select id, name, price, tag from Product where id = #{id}" ) public Product selectOne( @Param("id") int id); }
这是在xml中编写的另一种方式:
不需要结果映射,因为列可以直接映射到对象属性。
你可以这样写 –