Ejemplo n.º 1
0
 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();
   }
 }
Ejemplo n.º 2
0
 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();
   }
 }
Ejemplo n.º 3
0
 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;
 }
Ejemplo n.º 4
0
 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;
 }
Ejemplo n.º 5
0
 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;
 }