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

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

Introduction

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

Prototype

int delete(String statement, Object parameter);

Source Link

Document

Execute a delete statement.

Usage

From source file:shfq.Test.java

License:Apache License

private static void deleteById() {
    SqlSession session = null;
    try {//from ww  w  . ja va2  s  . c  o m
        Reader reader = Resources.getResourceAsReader("shfq/mybatis-config.xml");
        SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);
        session = sqlSessionFactory.openSession();
        int count = session.delete("Student.deleteStudentById", 9);
        System.out.println(count + " record was deleted");

    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        if (session != null) {
            session.close();
        }
    }

}

From source file:webim.dao.ibatis.WebimRoomDao.java

License:Apache License

public void leaveRoom(String roomId, String uid) {
    Map<String, String> params = new HashMap<String, String>();
    params.put("room", roomId);
    params.put("uid", uid);
    SqlSession session = sessionFactory.openSession();
    try {//ww w  .  j a v  a 2 s .  c  om
        session.delete("RoomMapper.deleteMember", params);
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        session.close();
    }
}