@Test public void testGetPostById() throws Exception { Post post = postService.getPostById(1); Assert.assertNotNull(post); }
@Override public Post getPostById(int id) { SqlSession sqlSession = null; try { sqlSession = MybatisUtil.getSqlSession(); PostMapper postMapper = sqlSession.getMapper(PostMapper.class); return postMapper.getPostById(id); } catch (Exception e) { e.printStackTrace(); } finally { if (sqlSession != null) { sqlSession.close(); } } return null; }
PostServiceImpl implements PostService { @Override public Post getPostById(int id) { SqlSession sqlSession = null; try { sqlSession = MybatisUtil.getSqlSession(); PostMapper postMapper = sqlSession.getMapper(PostMapper.class); return postMapper.getPostById(id); } catch (Exception e) { e.printStackTrace(); } finally { if (sqlSession != null) { sqlSession.close(); } } return null; } }
PostServiceImpl implements PostService { @Override public Post getPostById(int id) { SqlSession sqlSession = null; try { sqlSession = MybatisUtil.getSqlSession(); PostMapper postMapper = sqlSession.getMapper(PostMapper.class); return postMapper.getPostById(id); } catch (Exception e) { e.printStackTrace(); } finally { if (sqlSession != null) { sqlSession.close(); } } return null; }  }
PostServiceImpl implements PostService { @Override public Post getPostById(int id) { SqlSession sqlSession = null; try { sqlSession = MybatisUtil.getSqlSession(); PostMapper postMapper = sqlSession.getMapper(PostMapper.class); return postMapper.getPostById(id); } catch (Exception e) { e.printStackTrace(); } finally { if (sqlSession != null) { sqlSession.close(); } } return null; }  @Override Post getPostById(int id); }
PostServiceImpl implements PostService { @Override public Post getPostById(int id) { SqlSession sqlSession = null; try { sqlSession = MybatisUtil.getSqlSession(); PostMapper postMapper = sqlSession.getMapper(PostMapper.class); return postMapper.getPostById(id); } catch (Exception e) { e.printStackTrace(); } finally { if (sqlSession != null) { sqlSession.close(); } } return null; }  @Override Post getPostById(int id);  }