Exemple #1
0
 public void selectByIdNamespaceWay(int id) {
   SqlSession session = sqlSessionFactory.openSession();
   try {
     User user =
         (User) session.selectOne("com.frames.mybatis.inter.UserMapper.selectUserByID", id);
     System.out.println(user.getUserAddress());
     System.out.println(user.getUserName());
   } finally {
     session.close();
   }
 }
Exemple #2
0
 public void selectByIdInterfaceWay(int id) {
   SqlSession session = sqlSessionFactory.openSession();
   try {
     IUserOperation userOperation = session.getMapper(IUserOperation.class);
     User user = userOperation.selectUserByID(id);
     System.out.println(user.getUserAddress());
     System.out.println(user.getUserName());
   } finally {
     session.close();
   }
 }
Exemple #3
0
  public void getUserList0(String userName) {
    SqlSession session = sqlSessionFactory.openSession();
    try {
      IUserOperation userOperation = session.getMapper(IUserOperation.class);
      List<User> users = userOperation.selectUsers0(userName);
      for (User user : users) {
        System.out.println(user.getId() + ":" + user.getUserName() + ":" + user.getUserAddress());
      }

    } finally {
      session.close();
    }
  }