Guest User

Untitled

a guest
Apr 22nd, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.74 KB | None | 0 0
  1. @SpringBootApplication
  2. public class SampleXMLApplication implements CommandLineRunner {
  3. public static void main(String[] args) {
  4. SpringApplication.run(SampleXMLApplication.class, args);
  5. }
  6. private final AuthorDao authorDao;
  7. private final ArticleDao articleDao;
  8. public SampleXMLApplication(AuthorDao authorDao, ArticleDao articleDao) {
  9. this.authorDao = authorDao;
  10. this.articleDao = articleDao;
  11. }
  12. @Override
  13. public void run(String... args) throws Exception {
  14. System.out.println(this.authorDao.selectAuthorById(2));
  15. System.out.println(this.articleDao.selectByAuthorId(2));
  16. }
  17. }
  18.  
  19. 2018-04-22 19:21:46.154 DEBUG 11964 --- [ main] s.m.m.AuthorMapper.selectAuthorById : ==> Preparing: select * from author where author_id = ?
  20. 2018-04-22 19:21:46.194 DEBUG 11964 --- [ main] s.m.m.AuthorMapper.selectAuthorById : ==> Parameters: 2(Long)
  21. 2018-04-22 19:21:46.209 TRACE 11964 --- [ main] s.m.m.AuthorMapper.selectAuthorById : <== Columns: author_id, name, surname
  22. 2018-04-22 19:21:46.210 TRACE 11964 --- [ main] s.m.m.AuthorMapper.selectAuthorById : <== Row: 2, Eric, Pugh
  23. 2018-04-22 19:21:46.221 DEBUG 11964 --- [ main] s.m.m.AuthorMapper.selectAuthorById : <== Total: 1
  24. [0,Eric,Eric,Pugh]
  25. 2018-04-22 19:21:46.224 DEBUG 11964 --- [ main] s.m.m.ArticleMapper.selectByAuthorId : ==> Preparing: select * from articles where author_id = ?
  26. 2018-04-22 19:21:46.224 DEBUG 11964 --- [ main] s.m.m.ArticleMapper.selectByAuthorId : ==> Parameters: 2(Long)
  27. 2018-04-22 19:21:46.226 TRACE 11964 --- [ main] s.m.m.ArticleMapper.selectByAuthorId : <== Columns: article_id, title, category, author_id
  28. 2018-04-22 19:21:46.226 TRACE 11964 --- [ main] s.m.m.ArticleMapper.selectByAuthorId : <== Row: 2, Hibernate HQL, Hibernate, 2
  29. 2018-04-22 19:21:46.227 TRACE 11964 --- [ main] s.m.m.ArticleMapper.selectByAuthorId : <== Row: 3, Java Concurrency, Java, 2
  30. 2018-04-22 19:21:46.228 DEBUG 11964 --- [ main] s.m.m.ArticleMapper.selectByAuthorId : <== Total: 2
  31.  
  32. @Controller
  33. @RequestMapping(value="/rest")
  34. public class AuthorController {
  35.  
  36. @Autowired
  37. private AuthorDao authorDao;
  38.  
  39. @GetMapping("articlesByAuthor/{authorId}")
  40. public List<Author> selectAuthorById(long id) {
  41. return authorDao.selectAuthorById(id);
  42. }
  43. }
  44.  
  45. . ____ _ __ _ _
  46. /\ / ___'_ __ _ _(_)_ __ __ _
  47. ( ( )___ | '_ | '_| | '_ / _` |
  48. \/ ___)| |_)| | | | | || (_| | ) ) ) )
  49. ' |____| .__|_| |_|_| |___, | / / / /
  50. =========|_|==============|___/=/_/_/_/
  51. :: Spring Boot :: (v1.5.10.RELEASE)
  52.  
  53.  
  54. Process finished with exit code 0
Add Comment
Please, Sign In to add comment