Skip to content

Final homework submission - #3

Open
obvly wants to merge 5 commits into
mainfrom
submission
Open

obvly wants to merge 5 commits into
mainfrom
submission

Conversation

@obvly

@obvly obvly commented Sep 17, 2026

Copy link
Copy Markdown
Owner

No description provided.

@Elena-Bruyako Elena-Bruyako left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix CI/CD
fix checkstyle
Have you done first Create repo HW?
see comments

Comment on lines +23 to +27
return bookService.getBookById(id);
}
@PostMapping
public BookDto createBook(@RequestBody CreateBookRequestDto bookDto) {
return bookService.createBook(bookDto);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return bookService.getBookById(id);
}
@PostMapping
public BookDto createBook(@RequestBody CreateBookRequestDto bookDto) {
return bookService.createBook(bookDto);
return bookService.getBookById(id);
}
@PostMapping
public BookDto createBook(@RequestBody CreateBookRequestDto bookDto) {
return bookService.createBook(bookDto);

public BookDto getBookById(@PathVariable Long id) {
return bookService.getBookById(id);
}
@PostMapping

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add status


@Entity
@Table(name = "books")
@Data

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't use @Data for entities

Suggested change
@Data
@Getter
@Setter

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String title;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add required constraints

import org.example.springbootweb.model.Book;
import org.springframework.data.jpa.repository.JpaRepository;

public interface BookRepository extends JpaRepository<Book, Long> {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should implement logic by using Session and Transaction

Comment on lines +8 to +10
BookDto createBook(CreateBookRequestDto bookDto);
List<BookDto> getAll();
BookDto getBookById(Long id);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
BookDto createBook(CreateBookRequestDto bookDto);
List<BookDto> getAll();
BookDto getBookById(Long id);
BookDto createBook(CreateBookRequestDto bookDto);
List<BookDto> getAll();
BookDto getBookById(Long id);

spring.datasource.password=password
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=update

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
spring.jpa.hibernate.ddl-auto=update
spring.jpa.hibernate.ddl-auto=create-drop

@@ -0,0 +1,7 @@
spring.datasource.url=jdbc:h2:mem:testdb

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

h2 is used only for test purposes

@obvly
obvly requested a review from Elena-Bruyako September 18, 2026 23:09

@Elena-Bruyako Elena-Bruyako left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see comments

}

@PostMapping
@ResponseStatus(HttpStatus.CREATED) // Add status 201

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@ResponseStatus(HttpStatus.CREATED) // Add status 201
@ResponseStatus(HttpStatus.CREATED)

Comment on lines +8 to +10
Book save(Book book);
List<Book> findAll();
Optional<Book> findById(Long id);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add emtpy lines between methods
check your checkstyle (looks like don't work properly)

Comment thread checkstyle.xml
@@ -0,0 +1,8 @@
<?xml version="1.0"?>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is wrong file
come back to the first HW (Create repo) and find correct version of the checkstyle file
if you have some issues - ask in chat

@obvly
obvly requested a review from Elena-Bruyako September 21, 2026 11:56

@Elena-Bruyako Elena-Bruyako left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, open Spring Boot Intro lesson -> Create a Repo and read requirements
Image

Aslo, fix CI/CD
See this section in Create a Repo task

Create a .github directory (pay attention to the folder name, it should start with . (dot)) in your project root directory. Inside this directory create a new directory workflows. (as an example please see [this project's](https://github.com/mate-academy/hibernate-relations-hw) structure)
Inside the workflows directory create a new file ci.yml and paste this code into it:
name: Java CI

on:
  - push
  - pull_request

jobs:
  build:
    runs-on: ubuntu-latest
    
    steps:
      - uses: actions/checkout@v4
      - name: Set up JDK 17
        uses: actions/setup-java@v4
        with:
          java-version: '17'
          distribution: 'temurin'
          cache: maven
      - name: Build with Maven
        run: mvn --batch-mode --update-snapshots verify

Comment thread checkstyle.xml
@@ -0,0 +1,22 @@
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

copy this file

@obvly
obvly requested a review from Elena-Bruyako September 21, 2026 21:36

@Elena-Bruyako Elena-Bruyako left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants