泛型

泛型<?>_第1张图片
SqlSessionFactory ssf = null;

    @Before
    public void init() {
        // 1.创建会话工厂
        try {
            InputStream in = Resources.getResourceAsStream("sqlMapConfig.xml");
            ssf = new SqlSessionFactoryBuilder().build(in);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

@Test
    public void findAll(){
        //获取sqlsession,执行SQL
        SqlSession session = ssf.openSession();
        //利用接口方法
        List>list = session.selectList("doorns.findAll");
        //处理结果
        for (Map map : list) {
            System.out.println(map);
        }
        //释放资源
        session.close();
    }

等价于

SqlSessionFactory ssf = null;

    @Before
    public void init() {
        // 1.创建会话工厂
        try {
            InputStream in = Resources.getResourceAsStream("sqlMapConfig.xml");
            ssf = new SqlSessionFactoryBuilder().build(in);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

@Test
    public void findAll(){
        //获取sqlsession,执行SQL
        SqlSession session = ssf.openSession();
        //利用接口方法
        List>list = session.selectList("doorns.findAll");
        //处理结果
        for (Map map : list) {
            System.out.println(map);
        }
        //释放资源
        session.close();
    }



    

你可能感兴趣的:(泛型)