Skip to content

Library2: API Rest Author Book @OneToMany CRUD with Swagger

Albert edited this page May 27, 2022 · 30 revisions

Welcome to the cifojava2022-3 wiki!

Spring Boot Projects: Library2

Base project

  • Base project:

New tools

  • Author @Entity
  • 1:n relationship: unidrectional or bidirectional
  • Annotations:
    • @OneToMany
    • @ManyToMany
    • @JoinColumn
  • JUnit Jupiter to test
    • ItellJIdea plug-in JUnit in action :

      JUnit Jupiter

    • Maven Dependency: link junit-jupiter-api/5.9.0-M1

           `<!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api -->`
                  `<dependency>`
                  `<groupId>org.junit.jupiter</groupId>`
                  `<artifactId>junit-jupiter-api</artifactId>`
                  `<version>5.9.0-M1</version>`
                  `<scope>test</scope>`
           `</dependency>`
      

Versions

  • version 1.0 : basic project:

    • Author and Book @Entity wiht basic CRUD operations (Read and Create)
    • without assigning Author <1:n> Book
    • bug : dob parsing wrong to H2-DB => just a typo dof instead of dob in constructor
    • BE CAREFUL :
      • infinite recuresion is running so ... @Jsonignore besides @ManyToOne (1)
      • also in toString so write it without author (2)
  • version 1.1 : tests done by JUnit and Swagger

  • version 1.2 : refactor and ddd (domains)

    • refactor to DDD,domains

      onetomany

    • responseEntity in action

      responseEntity

    • all CRUD book methods impplemented

      bookRestController

Check this: offcial repo book JPA