From 1c79e3a2983a811991338e87121cce5bad5581dc Mon Sep 17 00:00:00 2001 From: John Thompson Date: Tue, 16 May 2017 15:13:58 -0400 Subject: [PATCH 01/29] adding JPA example --- .../spring5webapp/model/Author.java | 67 ++++++++++++++++ .../spring5webapp/model/Book.java | 79 +++++++++++++++++++ src/main/resources/application.properties | 1 + 3 files changed, 147 insertions(+) create mode 100644 src/main/java/guru/springframework/spring5webapp/model/Author.java create mode 100644 src/main/java/guru/springframework/spring5webapp/model/Book.java diff --git a/src/main/java/guru/springframework/spring5webapp/model/Author.java b/src/main/java/guru/springframework/spring5webapp/model/Author.java new file mode 100644 index 0000000000..ff7d926325 --- /dev/null +++ b/src/main/java/guru/springframework/spring5webapp/model/Author.java @@ -0,0 +1,67 @@ +package guru.springframework.spring5webapp.model; + +import javax.persistence.*; +import java.util.HashSet; +import java.util.Set; + +/** + * Created by jt on 5/16/17. + */ +@Entity +public class Author { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private Long id; + private String firstName; + private String lastName; + + @ManyToMany(mappedBy = "authors") + private Set books = new HashSet<>(); + + public Author() { + } + + public Author(String firstName, String lastName) { + this.firstName = firstName; + this.lastName = lastName; + } + + public Author(String firstName, String lastName, Set books) { + this.firstName = firstName; + this.lastName = lastName; + this.books = books; + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public Set getBooks() { + return books; + } + + public void setBooks(Set books) { + this.books = books; + } +} diff --git a/src/main/java/guru/springframework/spring5webapp/model/Book.java b/src/main/java/guru/springframework/spring5webapp/model/Book.java new file mode 100644 index 0000000000..eb04853b53 --- /dev/null +++ b/src/main/java/guru/springframework/spring5webapp/model/Book.java @@ -0,0 +1,79 @@ +package guru.springframework.spring5webapp.model; + +import javax.persistence.*; +import java.util.HashSet; +import java.util.Set; + +/** + * Created by jt on 5/16/17. + */ +@Entity +public class Book { + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private Long id; + private String title; + private String isbn; + private String publisher; + + @ManyToMany + @JoinTable(name = "author_book", joinColumns = @JoinColumn(name = "book_id"), + inverseJoinColumns = @JoinColumn(name = "author_id")) + private Set authors = new HashSet<>(); + + public Book() { + } + + public Book(String title, String isbn, String publisher) { + this.title = title; + this.isbn = isbn; + this.publisher = publisher; + } + + public Book(String title, String isbn, String publisher, Set authors) { + this.title = title; + this.isbn = isbn; + this.publisher = publisher; + this.authors = authors; + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getIsbn() { + return isbn; + } + + public void setIsbn(String isbn) { + this.isbn = isbn; + } + + public String getPublisher() { + return publisher; + } + + public void setPublisher(String publisher) { + this.publisher = publisher; + } + + public Set getAuthors() { + return authors; + } + + public void setAuthors(Set authors) { + this.authors = authors; + } +} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index e69de29bb2..69b89983cb 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -0,0 +1 @@ +spring.h2.console.enabled=true \ No newline at end of file From af9c8e81c7a9e34f984eb621334aaff1de8b032e Mon Sep 17 00:00:00 2001 From: John Thompson Date: Tue, 16 May 2017 16:16:14 -0400 Subject: [PATCH 02/29] adding JPA example --- .../spring5webapp/repositories/AuthorRepository.java | 10 ++++++++++ .../spring5webapp/repositories/BookRepository.java | 10 ++++++++++ 2 files changed, 20 insertions(+) create mode 100644 src/main/java/guru/springframework/spring5webapp/repositories/AuthorRepository.java create mode 100644 src/main/java/guru/springframework/spring5webapp/repositories/BookRepository.java diff --git a/src/main/java/guru/springframework/spring5webapp/repositories/AuthorRepository.java b/src/main/java/guru/springframework/spring5webapp/repositories/AuthorRepository.java new file mode 100644 index 0000000000..e0946f3e5c --- /dev/null +++ b/src/main/java/guru/springframework/spring5webapp/repositories/AuthorRepository.java @@ -0,0 +1,10 @@ +package guru.springframework.spring5webapp.repositories; + +import guru.springframework.spring5webapp.model.Author; +import org.springframework.data.repository.CrudRepository; + +/** + * Created by jt on 5/16/17. + */ +public interface AuthorRepository extends CrudRepository { +} diff --git a/src/main/java/guru/springframework/spring5webapp/repositories/BookRepository.java b/src/main/java/guru/springframework/spring5webapp/repositories/BookRepository.java new file mode 100644 index 0000000000..a38ff57e5f --- /dev/null +++ b/src/main/java/guru/springframework/spring5webapp/repositories/BookRepository.java @@ -0,0 +1,10 @@ +package guru.springframework.spring5webapp.repositories; + +import guru.springframework.spring5webapp.model.Book; +import org.springframework.data.repository.CrudRepository; + +/** + * Created by jt on 5/16/17. + */ +public interface BookRepository extends CrudRepository { +} From 80bf60bd81c295e811907318c89feeeb34600f43 Mon Sep 17 00:00:00 2001 From: John Thompson Date: Tue, 16 May 2017 16:44:15 -0400 Subject: [PATCH 03/29] adding bootstrap class --- .../spring5webapp/bootstrap/DevBootstrap.java | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 src/main/java/guru/springframework/spring5webapp/bootstrap/DevBootstrap.java diff --git a/src/main/java/guru/springframework/spring5webapp/bootstrap/DevBootstrap.java b/src/main/java/guru/springframework/spring5webapp/bootstrap/DevBootstrap.java new file mode 100644 index 0000000000..d298bdd1d4 --- /dev/null +++ b/src/main/java/guru/springframework/spring5webapp/bootstrap/DevBootstrap.java @@ -0,0 +1,50 @@ +package guru.springframework.spring5webapp.bootstrap; + +import guru.springframework.spring5webapp.model.Author; +import guru.springframework.spring5webapp.model.Book; +import guru.springframework.spring5webapp.repositories.AuthorRepository; +import guru.springframework.spring5webapp.repositories.BookRepository; +import org.springframework.context.ApplicationListener; +import org.springframework.context.event.ContextRefreshedEvent; +import org.springframework.stereotype.Component; + +/** + * Created by jt on 5/16/17. + */ +@Component +public class DevBootstrap implements ApplicationListener { + + private AuthorRepository authorRepository; + private BookRepository bookRepository; + + public DevBootstrap(AuthorRepository authorRepository, BookRepository bookRepository) { + this.authorRepository = authorRepository; + this.bookRepository = bookRepository; + } + + @Override + public void onApplicationEvent(ContextRefreshedEvent contextRefreshedEvent) { + initData(); + } + + private void initData(){ + + //Eric + Author eric = new Author("Eric", "Evans"); + Book ddd = new Book("Domain Driven Design", "1234", "Harper Collins"); + eric.getBooks().add(ddd); + ddd.getAuthors().add(eric); + + authorRepository.save(eric); + bookRepository.save(ddd); + + + //Rod + Author rod = new Author("Rod", "Johnson"); + Book noEJB = new Book("J2EE Development without EJB", "23444", "Worx" ); + rod.getBooks().add(noEJB); + + authorRepository.save(rod); + bookRepository.save(noEJB); + } +} From acb22fb229b238acd69786b3ceb532e269d87738 Mon Sep 17 00:00:00 2001 From: John Thompson Date: Wed, 17 May 2017 18:26:02 -0400 Subject: [PATCH 04/29] completed assignment review --- .../spring5webapp/bootstrap/DevBootstrap.java | 15 +++++-- .../spring5webapp/model/Book.java | 12 +++--- .../spring5webapp/model/Publisher.java | 43 +++++++++++++++++++ .../repositories/PublisherRepository.java | 10 +++++ 4 files changed, 72 insertions(+), 8 deletions(-) create mode 100644 src/main/java/guru/springframework/spring5webapp/model/Publisher.java create mode 100644 src/main/java/guru/springframework/spring5webapp/repositories/PublisherRepository.java diff --git a/src/main/java/guru/springframework/spring5webapp/bootstrap/DevBootstrap.java b/src/main/java/guru/springframework/spring5webapp/bootstrap/DevBootstrap.java index d298bdd1d4..88a65a0940 100644 --- a/src/main/java/guru/springframework/spring5webapp/bootstrap/DevBootstrap.java +++ b/src/main/java/guru/springframework/spring5webapp/bootstrap/DevBootstrap.java @@ -2,8 +2,10 @@ import guru.springframework.spring5webapp.model.Author; import guru.springframework.spring5webapp.model.Book; +import guru.springframework.spring5webapp.model.Publisher; import guru.springframework.spring5webapp.repositories.AuthorRepository; import guru.springframework.spring5webapp.repositories.BookRepository; +import guru.springframework.spring5webapp.repositories.PublisherRepository; import org.springframework.context.ApplicationListener; import org.springframework.context.event.ContextRefreshedEvent; import org.springframework.stereotype.Component; @@ -16,10 +18,12 @@ public class DevBootstrap implements ApplicationListener private AuthorRepository authorRepository; private BookRepository bookRepository; + private PublisherRepository publisherRepository; - public DevBootstrap(AuthorRepository authorRepository, BookRepository bookRepository) { + public DevBootstrap(AuthorRepository authorRepository, BookRepository bookRepository, PublisherRepository publisherRepository) { this.authorRepository = authorRepository; this.bookRepository = bookRepository; + this.publisherRepository = publisherRepository; } @Override @@ -29,9 +33,14 @@ public void onApplicationEvent(ContextRefreshedEvent contextRefreshedEvent) { private void initData(){ + Publisher publisher = new Publisher(); + publisher.setName("foo"); + + publisherRepository.save(publisher); + //Eric Author eric = new Author("Eric", "Evans"); - Book ddd = new Book("Domain Driven Design", "1234", "Harper Collins"); + Book ddd = new Book("Domain Driven Design", "1234", publisher); eric.getBooks().add(ddd); ddd.getAuthors().add(eric); @@ -41,7 +50,7 @@ private void initData(){ //Rod Author rod = new Author("Rod", "Johnson"); - Book noEJB = new Book("J2EE Development without EJB", "23444", "Worx" ); + Book noEJB = new Book("J2EE Development without EJB", "23444", publisher ); rod.getBooks().add(noEJB); authorRepository.save(rod); diff --git a/src/main/java/guru/springframework/spring5webapp/model/Book.java b/src/main/java/guru/springframework/spring5webapp/model/Book.java index eb04853b53..7d50cc673f 100644 --- a/src/main/java/guru/springframework/spring5webapp/model/Book.java +++ b/src/main/java/guru/springframework/spring5webapp/model/Book.java @@ -14,7 +14,9 @@ public class Book { private Long id; private String title; private String isbn; - private String publisher; + + @OneToOne + private Publisher publisher; @ManyToMany @JoinTable(name = "author_book", joinColumns = @JoinColumn(name = "book_id"), @@ -24,13 +26,13 @@ public class Book { public Book() { } - public Book(String title, String isbn, String publisher) { + public Book(String title, String isbn, Publisher publisher) { this.title = title; this.isbn = isbn; this.publisher = publisher; } - public Book(String title, String isbn, String publisher, Set authors) { + public Book(String title, String isbn, Publisher publisher, Set authors) { this.title = title; this.isbn = isbn; this.publisher = publisher; @@ -61,11 +63,11 @@ public void setIsbn(String isbn) { this.isbn = isbn; } - public String getPublisher() { + public Publisher getPublisher() { return publisher; } - public void setPublisher(String publisher) { + public void setPublisher(Publisher publisher) { this.publisher = publisher; } diff --git a/src/main/java/guru/springframework/spring5webapp/model/Publisher.java b/src/main/java/guru/springframework/spring5webapp/model/Publisher.java new file mode 100644 index 0000000000..13d0e131da --- /dev/null +++ b/src/main/java/guru/springframework/spring5webapp/model/Publisher.java @@ -0,0 +1,43 @@ +package guru.springframework.spring5webapp.model; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; + +/** + * Created by jt on 5/17/17. + */ +@Entity +public class Publisher { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private Long id; + private String name; + private String address; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } +} diff --git a/src/main/java/guru/springframework/spring5webapp/repositories/PublisherRepository.java b/src/main/java/guru/springframework/spring5webapp/repositories/PublisherRepository.java new file mode 100644 index 0000000000..63a986bcf6 --- /dev/null +++ b/src/main/java/guru/springframework/spring5webapp/repositories/PublisherRepository.java @@ -0,0 +1,10 @@ +package guru.springframework.spring5webapp.repositories; + +import guru.springframework.spring5webapp.model.Publisher; +import org.springframework.data.repository.CrudRepository; + +/** + * Created by jt on 5/17/17. + */ +public interface PublisherRepository extends CrudRepository { +} From 336341e6a8056a1af4c7f675fe806356306a5d12 Mon Sep 17 00:00:00 2001 From: John Thompson Date: Thu, 18 May 2017 12:34:56 -0400 Subject: [PATCH 05/29] adding book controller --- .../controllers/BookController.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/main/java/guru/springframework/spring5webapp/controllers/BookController.java diff --git a/src/main/java/guru/springframework/spring5webapp/controllers/BookController.java b/src/main/java/guru/springframework/spring5webapp/controllers/BookController.java new file mode 100644 index 0000000000..84399cb87d --- /dev/null +++ b/src/main/java/guru/springframework/spring5webapp/controllers/BookController.java @@ -0,0 +1,27 @@ +package guru.springframework.spring5webapp.controllers; + +import guru.springframework.spring5webapp.repositories.BookRepository; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.RequestMapping; + +/** + * Created by jt on 5/18/17. + */ +@Controller +public class BookController { + + private BookRepository bookRepository; + + public BookController(BookRepository bookRepository) { + this.bookRepository = bookRepository; + } + + @RequestMapping("/books") + public String getBooks(Model model){ + + model.addAttribute("books", bookRepository.findAll()); + + return "books"; + } +} From 95e4dd0387d1cdbf7e74d1fa985861aff88d7247 Mon Sep 17 00:00:00 2001 From: John Thompson Date: Thu, 18 May 2017 15:11:40 -0400 Subject: [PATCH 06/29] adding book template --- src/main/resources/templates/books.html | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/main/resources/templates/books.html diff --git a/src/main/resources/templates/books.html b/src/main/resources/templates/books.html new file mode 100644 index 0000000000..6796e39e28 --- /dev/null +++ b/src/main/resources/templates/books.html @@ -0,0 +1,24 @@ + + + + + Spring Framework Guru + + +

Book List

+ + + + + + + + + + + + +
IDTitlePublisher
123Spring in ActionWrox
+ + + \ No newline at end of file From 423cecda47360211eb2ce41a07599b962ea56e0d Mon Sep 17 00:00:00 2001 From: John Thompson Date: Thu, 18 May 2017 15:38:32 -0400 Subject: [PATCH 07/29] adding book template --- .../controllers/AuthorController.java | 27 +++++++++++++++++++ src/main/resources/templates/authors.html | 24 +++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 src/main/java/guru/springframework/spring5webapp/controllers/AuthorController.java create mode 100644 src/main/resources/templates/authors.html diff --git a/src/main/java/guru/springframework/spring5webapp/controllers/AuthorController.java b/src/main/java/guru/springframework/spring5webapp/controllers/AuthorController.java new file mode 100644 index 0000000000..374aeb8ec2 --- /dev/null +++ b/src/main/java/guru/springframework/spring5webapp/controllers/AuthorController.java @@ -0,0 +1,27 @@ +package guru.springframework.spring5webapp.controllers; + +import guru.springframework.spring5webapp.repositories.AuthorRepository; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.RequestMapping; + +/** + * Created by jt on 5/18/17. + */ +@Controller +public class AuthorController { + + private AuthorRepository authorRepository; + + public AuthorController(AuthorRepository authorRepository) { + this.authorRepository = authorRepository; + } + + @RequestMapping("/authors") + public String getAuthors(Model model){ + + model.addAttribute("authors", authorRepository.findAll()); + + return "authors"; + } +} diff --git a/src/main/resources/templates/authors.html b/src/main/resources/templates/authors.html new file mode 100644 index 0000000000..48e1668d68 --- /dev/null +++ b/src/main/resources/templates/authors.html @@ -0,0 +1,24 @@ + + + + + Spring Framework Guru + + +

Author List

+ + + + + + + + + + + + +
IDFirst NameLast
123JoeBuck
+ + + \ No newline at end of file From 9b4b0f5c8d06f61aa1b48795ae4b5210221119ab Mon Sep 17 00:00:00 2001 From: John Thompson Date: Mon, 19 Jun 2017 13:53:46 -0400 Subject: [PATCH 08/29] Updating Spring Boot Version --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index deb18b1374..a9350676b0 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ org.springframework.boot spring-boot-starter-parent - 2.0.0.BUILD-SNAPSHOT + 2.0.0.M2 From 057a7e58aec93faf3cd4d00f646e55120c243c50 Mon Sep 17 00:00:00 2001 From: John Thompson Date: Mon, 19 Jun 2017 13:54:11 -0400 Subject: [PATCH 09/29] Updating Spring Boot Version --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index deb18b1374..a9350676b0 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ org.springframework.boot spring-boot-starter-parent - 2.0.0.BUILD-SNAPSHOT + 2.0.0.M2 From b3c04f4d470cf662706ac6bb7b15a81ffb73d408 Mon Sep 17 00:00:00 2001 From: John Thompson Date: Mon, 19 Jun 2017 13:54:32 -0400 Subject: [PATCH 10/29] Updating Spring Boot Version --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index deb18b1374..a9350676b0 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ org.springframework.boot spring-boot-starter-parent - 2.0.0.BUILD-SNAPSHOT + 2.0.0.M2 From 7f628f2dcc21c82ec367a004b09d0bb6fc5bb045 Mon Sep 17 00:00:00 2001 From: John Thompson Date: Mon, 19 Jun 2017 13:54:50 -0400 Subject: [PATCH 11/29] Updating Spring Boot Version --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index deb18b1374..a9350676b0 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ org.springframework.boot spring-boot-starter-parent - 2.0.0.BUILD-SNAPSHOT + 2.0.0.M2 From 52bbd03af31b829966df99eaba7e4b69f31e81f1 Mon Sep 17 00:00:00 2001 From: John Thompson Date: Mon, 19 Jun 2017 13:55:10 -0400 Subject: [PATCH 12/29] Updating Spring Boot Version --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index deb18b1374..a9350676b0 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ org.springframework.boot spring-boot-starter-parent - 2.0.0.BUILD-SNAPSHOT + 2.0.0.M2 From 405e6a6a22d82a1589b4828a9901cb9d6f66935f Mon Sep 17 00:00:00 2001 From: John Thompson Date: Mon, 19 Jun 2017 13:55:31 -0400 Subject: [PATCH 13/29] Updating Spring Boot Version --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index deb18b1374..a9350676b0 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ org.springframework.boot spring-boot-starter-parent - 2.0.0.BUILD-SNAPSHOT + 2.0.0.M2 From 248ef06d7385669200bda7e0b5ec6a43304b080c Mon Sep 17 00:00:00 2001 From: John Thompson Date: Mon, 19 Jun 2017 13:55:59 -0400 Subject: [PATCH 14/29] Updating Spring Boot Version --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index deb18b1374..a9350676b0 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ org.springframework.boot spring-boot-starter-parent - 2.0.0.BUILD-SNAPSHOT + 2.0.0.M2 From ee5272e39285327876d7bd04d96a0ff2573cf9d8 Mon Sep 17 00:00:00 2001 From: John Thompson Date: Mon, 31 Jul 2017 16:44:32 -0400 Subject: [PATCH 15/29] Updating Spring Boot Version --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a9350676b0..db64bfd00c 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ org.springframework.boot spring-boot-starter-parent - 2.0.0.M2 + 2.0.0.M3 From a0f05efae5d0bd1c5e2c2c61fc6d492e854129f4 Mon Sep 17 00:00:00 2001 From: John Thompson Date: Mon, 31 Jul 2017 16:46:31 -0400 Subject: [PATCH 16/29] Updating Spring Boot Version --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a9350676b0..db64bfd00c 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ org.springframework.boot spring-boot-starter-parent - 2.0.0.M2 + 2.0.0.M3 From 6648cfb90dfe9a93dd7aafddff2f93bc8719f45a Mon Sep 17 00:00:00 2001 From: John Thompson Date: Mon, 31 Jul 2017 16:47:03 -0400 Subject: [PATCH 17/29] Updating Spring Boot Version --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a9350676b0..db64bfd00c 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ org.springframework.boot spring-boot-starter-parent - 2.0.0.M2 + 2.0.0.M3 From f9fd77f63ab48e026abaa5b7286bd0111271e26b Mon Sep 17 00:00:00 2001 From: John Thompson Date: Mon, 31 Jul 2017 16:47:34 -0400 Subject: [PATCH 18/29] Updating Spring Boot Version --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a9350676b0..db64bfd00c 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ org.springframework.boot spring-boot-starter-parent - 2.0.0.M2 + 2.0.0.M3 From 451e5474c10947f7ded21f60c4f21d98ed75474f Mon Sep 17 00:00:00 2001 From: John Thompson Date: Mon, 31 Jul 2017 16:48:26 -0400 Subject: [PATCH 19/29] Updating Spring Boot Version --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a9350676b0..db64bfd00c 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ org.springframework.boot spring-boot-starter-parent - 2.0.0.M2 + 2.0.0.M3 From 3ed1e95dddd2826d497ae3533e8841f8e587b164 Mon Sep 17 00:00:00 2001 From: John Thompson Date: Mon, 31 Jul 2017 16:49:04 -0400 Subject: [PATCH 20/29] Updating Spring Boot Version --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a9350676b0..db64bfd00c 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ org.springframework.boot spring-boot-starter-parent - 2.0.0.M2 + 2.0.0.M3 From a6564a73966ce0f59b06f356101a874880e56c0a Mon Sep 17 00:00:00 2001 From: John Thompson Date: Mon, 31 Jul 2017 16:49:45 -0400 Subject: [PATCH 21/29] Updating Spring Boot Version --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a9350676b0..db64bfd00c 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ org.springframework.boot spring-boot-starter-parent - 2.0.0.M2 + 2.0.0.M3 From 57ad1aeaff0fef4814d8cb64c6cfc2103005ae8f Mon Sep 17 00:00:00 2001 From: Tiago Teixeira Date: Thu, 24 Aug 2017 01:15:58 +0100 Subject: [PATCH 22/29] Corrected typo Worx to Wrox Book link: http://www.wrox.com/WileyCDA/WroxTitle/Expert-One-on-One-J2EE-Development-without-EJB.productCd-0764558315.html --- .../springframework/spring5webapp/bootstrap/DevBootstrap.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/guru/springframework/spring5webapp/bootstrap/DevBootstrap.java b/src/main/java/guru/springframework/spring5webapp/bootstrap/DevBootstrap.java index d298bdd1d4..3917936801 100644 --- a/src/main/java/guru/springframework/spring5webapp/bootstrap/DevBootstrap.java +++ b/src/main/java/guru/springframework/spring5webapp/bootstrap/DevBootstrap.java @@ -41,7 +41,7 @@ private void initData(){ //Rod Author rod = new Author("Rod", "Johnson"); - Book noEJB = new Book("J2EE Development without EJB", "23444", "Worx" ); + Book noEJB = new Book("J2EE Development without EJB", "23444", "Wrox" ); rod.getBooks().add(noEJB); authorRepository.save(rod); From 3692bd466bbd04e2f4da28c773262786a4fa679c Mon Sep 17 00:00:00 2001 From: John Thompson Date: Thu, 7 Sep 2017 14:53:36 -0400 Subject: [PATCH 23/29] adding equals, hash, and toString --- .../spring5webapp/model/Author.java | 25 ++++++++++++++++++ .../spring5webapp/model/Book.java | 26 +++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/src/main/java/guru/springframework/spring5webapp/model/Author.java b/src/main/java/guru/springframework/spring5webapp/model/Author.java index ff7d926325..1768e9c794 100644 --- a/src/main/java/guru/springframework/spring5webapp/model/Author.java +++ b/src/main/java/guru/springframework/spring5webapp/model/Author.java @@ -64,4 +64,29 @@ public Set getBooks() { public void setBooks(Set books) { this.books = books; } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + Author author = (Author) o; + + return id != null ? id.equals(author.id) : author.id == null; + } + + @Override + public int hashCode() { + return id != null ? id.hashCode() : 0; + } + + @Override + public String toString() { + return "Author{" + + "id=" + id + + ", firstName='" + firstName + '\'' + + ", lastName='" + lastName + '\'' + + ", books=" + books + + '}'; + } } diff --git a/src/main/java/guru/springframework/spring5webapp/model/Book.java b/src/main/java/guru/springframework/spring5webapp/model/Book.java index eb04853b53..a1886b742c 100644 --- a/src/main/java/guru/springframework/spring5webapp/model/Book.java +++ b/src/main/java/guru/springframework/spring5webapp/model/Book.java @@ -76,4 +76,30 @@ public Set getAuthors() { public void setAuthors(Set authors) { this.authors = authors; } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + Book book = (Book) o; + + return id != null ? id.equals(book.id) : book.id == null; + } + + @Override + public int hashCode() { + return id != null ? id.hashCode() : 0; + } + + @Override + public String toString() { + return "Book{" + + "id=" + id + + ", title='" + title + '\'' + + ", isbn='" + isbn + '\'' + + ", publisher='" + publisher + '\'' + + ", authors=" + authors + + '}'; + } } From f5f75c5de45597c9cfb02812617ebc3320c1d9e0 Mon Sep 17 00:00:00 2001 From: John Thompson Date: Thu, 7 Sep 2017 15:06:28 -0400 Subject: [PATCH 24/29] adding equals, hash, and toString --- .../spring5webapp/model/Publisher.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/main/java/guru/springframework/spring5webapp/model/Publisher.java b/src/main/java/guru/springframework/spring5webapp/model/Publisher.java index 13d0e131da..a7e22888a2 100644 --- a/src/main/java/guru/springframework/spring5webapp/model/Publisher.java +++ b/src/main/java/guru/springframework/spring5webapp/model/Publisher.java @@ -40,4 +40,28 @@ public String getAddress() { public void setAddress(String address) { this.address = address; } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + Publisher publisher = (Publisher) o; + + return id != null ? id.equals(publisher.id) : publisher.id == null; + } + + @Override + public int hashCode() { + return id != null ? id.hashCode() : 0; + } + + @Override + public String toString() { + return "Publisher{" + + "id=" + id + + ", name='" + name + '\'' + + ", address='" + address + '\'' + + '}'; + } } From cade2fbcc036d9cc38da32526e59b40a75939726 Mon Sep 17 00:00:00 2001 From: John Thompson Date: Wed, 4 Oct 2017 08:35:32 -0400 Subject: [PATCH 25/29] fix to Rod mapping --- .../springframework/spring5webapp/bootstrap/DevBootstrap.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/guru/springframework/spring5webapp/bootstrap/DevBootstrap.java b/src/main/java/guru/springframework/spring5webapp/bootstrap/DevBootstrap.java index 3917936801..a30f3a27f7 100644 --- a/src/main/java/guru/springframework/spring5webapp/bootstrap/DevBootstrap.java +++ b/src/main/java/guru/springframework/spring5webapp/bootstrap/DevBootstrap.java @@ -43,6 +43,7 @@ private void initData(){ Author rod = new Author("Rod", "Johnson"); Book noEJB = new Book("J2EE Development without EJB", "23444", "Wrox" ); rod.getBooks().add(noEJB); + noEJB.getAuthors().add(rod); authorRepository.save(rod); bookRepository.save(noEJB); From 901d258618752cbeeddade0d55cd1848f9177a40 Mon Sep 17 00:00:00 2001 From: John Thompson Date: Wed, 4 Oct 2017 08:39:26 -0400 Subject: [PATCH 26/29] merge fix --- .../springframework/spring5webapp/bootstrap/DevBootstrap.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/guru/springframework/spring5webapp/bootstrap/DevBootstrap.java b/src/main/java/guru/springframework/spring5webapp/bootstrap/DevBootstrap.java index 6b3f20dc61..42f4d871f3 100644 --- a/src/main/java/guru/springframework/spring5webapp/bootstrap/DevBootstrap.java +++ b/src/main/java/guru/springframework/spring5webapp/bootstrap/DevBootstrap.java @@ -50,7 +50,7 @@ private void initData(){ //Rod Author rod = new Author("Rod", "Johnson"); - Book noEJB = new Book("J2EE Development without EJB", "23444", "Wrox" ); + Book noEJB = new Book("J2EE Development without EJB", "23444", publisher ); rod.getBooks().add(noEJB); noEJB.getAuthors().add(rod); From 63af265b9960d7afff9c4f6f14b62e06a30559b4 Mon Sep 17 00:00:00 2001 From: springframeworkguru Date: Sun, 10 Dec 2017 08:15:08 +0530 Subject: [PATCH 27/29] Updated to 2.0.0.M7 --- pom.xml | 2 +- .../springframework/spring5webapp/bootstrap/DevBootstrap.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 4495165e07..209f115ce4 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ org.springframework.boot spring-boot-starter-parent - 2.0.0.M5 + 2.0.0.M7 diff --git a/src/main/java/guru/springframework/spring5webapp/bootstrap/DevBootstrap.java b/src/main/java/guru/springframework/spring5webapp/bootstrap/DevBootstrap.java index 42f4d871f3..53d074c71c 100644 --- a/src/main/java/guru/springframework/spring5webapp/bootstrap/DevBootstrap.java +++ b/src/main/java/guru/springframework/spring5webapp/bootstrap/DevBootstrap.java @@ -35,7 +35,7 @@ private void initData(){ Publisher publisher = new Publisher(); publisher.setName("foo"); - + publisher.setAddress("12th Street, LA"); publisherRepository.save(publisher); //Eric From fd8669905cba955e64d688f404a4441b3df7c3bc Mon Sep 17 00:00:00 2001 From: springframeworkguru Date: Sat, 17 Mar 2018 20:12:02 +0530 Subject: [PATCH 28/29] Updated to Spring Boot 2.0.0.RELEASE --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 209f115ce4..c1260dc5bd 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ org.springframework.boot spring-boot-starter-parent - 2.0.0.M7 + 2.0.0.RELEASE From cdbd54b605a2726b90ccb28a0bf4c468aaee3b74 Mon Sep 17 00:00:00 2001 From: springframeworkguru Date: Tue, 4 Dec 2018 01:03:19 +0530 Subject: [PATCH 29/29] Upgraded to Spring Boot 2.1.0.RELEASE --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c1260dc5bd..eb12eaf80d 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ org.springframework.boot spring-boot-starter-parent - 2.0.0.RELEASE + 2.1.0.RELEASE