private void updateMap(Map map) { SqlSession session = null; try { session = factory.openSession(); UserMapper mapper = session.getMapper(UserMapper.class); mapper.updateMap(map); session.commit(); } catch (Exception e) { e.printStackTrace(); } finally { session.close(); } }
private void deleteUser(User user) { SqlSession session = null; try { session = factory.openSession(); UserMapper mapper = session.getMapper(UserMapper.class); mapper.deleteUser(user); session.commit(); } catch (Exception e) { e.printStackTrace(); } finally { session.close(); } }
private List<User> getUserByName(String name) { SqlSession session = null; List<User> list = null; try { session = factory.openSession(); UserMapper mapper = session.getMapper(UserMapper.class); list = mapper.getUserByName(name); } catch (Exception e) { e.printStackTrace(); } finally { session.close(); } return list; }
private User getUserById(int id) { SqlSession session = null; User user = null; try { session = factory.openSession(); UserMapper userMapper = session.getMapper(UserMapper.class); user = userMapper.getUserById(id); } catch (Exception e) { e.printStackTrace(); } finally { session.close(); } return user; }
private User selectTrim(User user) { SqlSession session = null; User userTrim = null; try { session = factory.openSession(); UserMapper mapper = session.getMapper(UserMapper.class); userTrim = mapper.selectTrim(user); } catch (Exception e) { e.printStackTrace(); } finally { session.close(); } return userTrim; }