Example usage for org.apache.ibatis.session SqlSession selectList

List of usage examples for org.apache.ibatis.session SqlSession selectList

Introduction

In this page you can find the example usage for org.apache.ibatis.session SqlSession selectList.

Prototype

<E> List<E> selectList(String statement, Object parameter);

Source Link

Document

Retrieve a list of mapped objects from the statement key and parameter.

Usage

From source file:org.mybatis.scripting.velocity.use.VelocityLanguageTest.java

License:Apache License

@Test
public void testDynamicSelectWithIterationComplex() {
    SqlSession sqlSession = sqlSessionFactory.openSession();
    try {//from w w w  .  j a  va  2s . co m

        Name[] names = { new Name(2), new Name(4), new Name(5) };
        Map<String, Name[]> param = new HashMap<String, Name[]>();
        param.put("names", names);
        List<Name> answer = sqlSession
                .selectList("org.mybatis.scripting.velocity.use.selectNamesWithIterationComplex", param);
        assertEquals(3, answer.size());
        for (int i = 0; i < names.length; i++) {
            assertEquals(names[i].getId(), answer.get(i).getId());
        }

    } finally {
        sqlSession.close();
    }
}

From source file:org.mybatis.scripting.velocity.use.VelocityLanguageTest.java

License:Apache License

@Test
public void testDynamicSelectWithIterationBoundary() {
    SqlSession sqlSession = sqlSessionFactory.openSession();
    try {//from w w w . j a v  a  2s .  c om

        List<Name> names = new ArrayList<Name>();
        for (int i = 0; i < 1001; i++) {
            names.add(new Name(i));
        }

        Map<String, List<Name>> param = new HashMap<String, List<Name>>();
        param.put("names", names);
        List<Name> answer = sqlSession
                .selectList("org.mybatis.scripting.velocity.use.selectNamesWithIterationComplex", param);
        assertEquals(5, answer.size());
    } finally {
        sqlSession.close();
    }
}

From source file:org.mybatis.scripting.velocity.use.VelocityLanguageTest.java

License:Apache License

@Test
public void testSelectWithCustomUserDirective() {
    SqlSession sqlSession = sqlSessionFactory.openSession();
    try {//ww w.  j a  v a2  s .  c  o  m
        Map<String, List<Name>> param = new HashMap<String, List<Name>>();
        List<Name> answer = sqlSession
                .selectList("org.mybatis.scripting.velocity.use.selectWithCustomUserDirective", param);
        assertEquals(5, answer.size());
    } finally {
        sqlSession.close();
    }
}

From source file:org.mybatis.scripting.velocity.use.VelocityLanguageTest.java

License:Apache License

@Test
public void testDynamicSelectWithInDirectiveForOneThousandPlusOne() {
    SqlSession sqlSession = sqlSessionFactory.openSession();
    try {/*  w  w w.j  av  a2 s.c o m*/
        List<Name> names = new ArrayList<Name>();
        for (int i = 0; i < 1001; i++) {
            names.add(new Name(i + 1));
        }

        Map<String, List<Name>> param = new HashMap<String, List<Name>>();
        param.put("names", names);
        List<Name> answer = sqlSession
                .selectList("org.mybatis.scripting.velocity.use.selectNamesWithInDirective", param);
        assertEquals(5, answer.size());
    } finally {
        sqlSession.close();
    }
}

From source file:org.mybatis.scripting.velocity.use.VelocityLanguageTest.java

License:Apache License

@Test
public void testDynamicSelectWithInDirectiveForOneThousand() {
    SqlSession sqlSession = sqlSessionFactory.openSession();
    try {/*from w w w. j  a v a2 s  .  c o  m*/
        List<Name> names = new ArrayList<Name>();
        for (int i = 0; i < 1000; i++) {
            names.add(new Name(i + 1));
        }

        Map<String, List<Name>> param = new HashMap<String, List<Name>>();
        param.put("names", names);
        List<Name> answer = sqlSession
                .selectList("org.mybatis.scripting.velocity.use.selectNamesWithInDirective", param);
        assertEquals(5, answer.size());
    } finally {
        sqlSession.close();
    }
}

From source file:org.mybatis.scripting.velocity.use.VelocityLanguageTest.java

License:Apache License

@Test
public void testDynamicSelectWithInDirectiveForOneThousandMinusOne() {
    SqlSession sqlSession = sqlSessionFactory.openSession();
    try {//from  w  ww .ja  va 2 s  .  co m
        List<Name> names = new ArrayList<Name>();
        for (int i = 0; i < 999; i++) {
            names.add(new Name(i + 1));
        }

        Map<String, List<Name>> param = new HashMap<String, List<Name>>();
        param.put("names", names);
        List<Name> answer = sqlSession
                .selectList("org.mybatis.scripting.velocity.use.selectNamesWithInDirective", param);
        assertEquals(5, answer.size());
    } finally {
        sqlSession.close();
    }
}

From source file:org.mybatis.scripting.velocity.use.VelocityLanguageTest.java

License:Apache License

@Test
public void testDynamicSelectWithInDirectiveForOneItem() {
    SqlSession sqlSession = sqlSessionFactory.openSession();
    try {/*from w  w  w .  j av a2 s.  c  om*/
        List<Name> names = new ArrayList<Name>();
        for (int i = 0; i < 1; i++) {
            names.add(new Name(i + 1));
        }

        Map<String, List<Name>> param = new HashMap<String, List<Name>>();
        param.put("names", names);
        List<Name> answer = sqlSession
                .selectList("org.mybatis.scripting.velocity.use.selectNamesWithInDirective", param);
        assertEquals(1, answer.size());
    } finally {
        sqlSession.close();
    }
}

From source file:org.restcomm.connect.dao.mybatis.MybatisAccountsDao.java

License:Open Source License

@Override
public List<Account> getChildAccounts(final Sid parentSid) {
    final SqlSession session = sessions.openSession();
    try {/*  ww  w.j  a va2s . co m*/
        final List<Map<String, Object>> results = session.selectList(namespace + "getChildAccounts",
                parentSid.toString());
        final List<Account> accounts = new ArrayList<Account>();
        if (results != null && !results.isEmpty()) {
            for (final Map<String, Object> result : results) {
                accounts.add(toAccount(result));
            }
        }
        return accounts;
    } finally {
        session.close();
    }
}

From source file:org.restcomm.connect.dao.mybatis.MybatisAccountsDao.java

License:Open Source License

private List<String> getSubAccountsSids(List<String> parentAccountSidList) {
    final SqlSession session = sessions.openSession();
    try {/*w  w w  .  ja  v a 2  s.  c o  m*/
        final List<String> results = session.selectList(namespace + "getSubAccountSids", parentAccountSidList);
        return results;
    } finally {
        session.close();
    }
}

From source file:org.restcomm.connect.dao.mybatis.MybatisGeolocationDao.java

License:Open Source License

@Override
public List<Geolocation> getGeolocations(Sid accountSid) {
    final SqlSession session = sessions.openSession();
    try {//from   w ww . j  av a 2  s  .  c  o  m
        final List<Map<String, Object>> results = session.selectList(namespace + "getGeolocations",
                accountSid.toString());
        final List<Geolocation> geolocations = new ArrayList<Geolocation>();
        if (results != null && !results.isEmpty()) {
            for (final Map<String, Object> result : results) {
                geolocations.add(toGeolocation(result));
            }
        }
        return geolocations;
    } finally {
        session.close();
    }
}