标签:factor oid val string static tor builder get size
<mappers> <!-- <mapper resource="com/bank/mapper/accountMapper.xml"/> <mapper resource="com/bank/mapper/LogMappery.xml"/> --> <package name="com.bank.mapper"/> </mappers>
public interface LogMappery { List<Log> selectAll(); }
<mapper namespace="com.bank.mapper"> <select id="selectAll" resultType="account"> select * from account </select>
</mapper>
public class TestMyBaits { public static void main(String[] args) throws IOException { InputStream is=Resources.getResourceAsStream("myBatis.xml"); SqlSessionFactory factory=new SqlSessionFactoryBuilder().build(is); SqlSession session=factory.openSession(); LogMappery logMappery=session.getMapper(LogMappery.class); List<Log> list=logMappery.selectAll(); for (Log l : list) { System.out.println(l); } } }
List<Log> selectPage(int pageStart,int pageSize);
<select id="selectPage" resultType="log"> select * from log limit #{0},#{1} </select>
<!-- #{}中使用0,1,2 或param1,param2 -->
List<Log> selectPage(@Param("pageStart")int pageStart,@Param("pageSize")int pageSize);
myBaits底层将参数转化为map , @Param("内容"),内容为key,传入参数为value;
<select id="selectPage" resultType="log"> select * from log limit #{pageStart},#{pageSize} </select>
标签:factor oid val string static tor builder get size
原文地址:https://www.cnblogs.com/lastingjava/p/9949916.html