Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @SpringBootApplication
- public class SampleXMLApplication implements CommandLineRunner {
- public static void main(String[] args) {
- SpringApplication.run(SampleXMLApplication.class, args);
- }
- private final AuthorDao authorDao;
- private final ArticleDao articleDao;
- public SampleXMLApplication(AuthorDao authorDao, ArticleDao articleDao) {
- this.authorDao = authorDao;
- this.articleDao = articleDao;
- }
- @Override
- public void run(String... args) throws Exception {
- System.out.println(this.authorDao.selectAuthorById(2));
- System.out.println(this.articleDao.selectByAuthorId(2));
- }
- }
- 2018-04-22 19:21:46.154 DEBUG 11964 --- [ main] s.m.m.AuthorMapper.selectAuthorById : ==> Preparing: select * from author where author_id = ?
- 2018-04-22 19:21:46.194 DEBUG 11964 --- [ main] s.m.m.AuthorMapper.selectAuthorById : ==> Parameters: 2(Long)
- 2018-04-22 19:21:46.209 TRACE 11964 --- [ main] s.m.m.AuthorMapper.selectAuthorById : <== Columns: author_id, name, surname
- 2018-04-22 19:21:46.210 TRACE 11964 --- [ main] s.m.m.AuthorMapper.selectAuthorById : <== Row: 2, Eric, Pugh
- 2018-04-22 19:21:46.221 DEBUG 11964 --- [ main] s.m.m.AuthorMapper.selectAuthorById : <== Total: 1
- [0,Eric,Eric,Pugh]
- 2018-04-22 19:21:46.224 DEBUG 11964 --- [ main] s.m.m.ArticleMapper.selectByAuthorId : ==> Preparing: select * from articles where author_id = ?
- 2018-04-22 19:21:46.224 DEBUG 11964 --- [ main] s.m.m.ArticleMapper.selectByAuthorId : ==> Parameters: 2(Long)
- 2018-04-22 19:21:46.226 TRACE 11964 --- [ main] s.m.m.ArticleMapper.selectByAuthorId : <== Columns: article_id, title, category, author_id
- 2018-04-22 19:21:46.226 TRACE 11964 --- [ main] s.m.m.ArticleMapper.selectByAuthorId : <== Row: 2, Hibernate HQL, Hibernate, 2
- 2018-04-22 19:21:46.227 TRACE 11964 --- [ main] s.m.m.ArticleMapper.selectByAuthorId : <== Row: 3, Java Concurrency, Java, 2
- 2018-04-22 19:21:46.228 DEBUG 11964 --- [ main] s.m.m.ArticleMapper.selectByAuthorId : <== Total: 2
- @Controller
- @RequestMapping(value="/rest")
- public class AuthorController {
- @Autowired
- private AuthorDao authorDao;
- @GetMapping("articlesByAuthor/{authorId}")
- public List<Author> selectAuthorById(long id) {
- return authorDao.selectAuthorById(id);
- }
- }
- . ____ _ __ _ _
- /\ / ___'_ __ _ _(_)_ __ __ _
- ( ( )___ | '_ | '_| | '_ / _` |
- \/ ___)| |_)| | | | | || (_| | ) ) ) )
- ' |____| .__|_| |_|_| |___, | / / / /
- =========|_|==============|___/=/_/_/_/
- :: Spring Boot :: (v1.5.10.RELEASE)
- Process finished with exit code 0
Add Comment
Please, Sign In to add comment