From 78991eb344e67d8517fbb78696ee948ea045e507 Mon Sep 17 00:00:00 2001 From: Elder Moraes Date: Thu, 5 Feb 2026 09:50:29 -0300 Subject: [PATCH] Minor fixes --- documentation/modules/ROOT/pages/04_panache.adoc | 1 + documentation/modules/ROOT/pages/07_spring.adoc | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/documentation/modules/ROOT/pages/04_panache.adoc b/documentation/modules/ROOT/pages/04_panache.adoc index b2149b6..48d8e88 100644 --- a/documentation/modules/ROOT/pages/04_panache.adoc +++ b/documentation/modules/ROOT/pages/04_panache.adoc @@ -320,6 +320,7 @@ package com.redhat.developers; import java.util.List; import io.quarkus.hibernate.orm.panache.PanacheEntity; +import jakarta.persistence.Column; import jakarta.persistence.Entity; @Entity diff --git a/documentation/modules/ROOT/pages/07_spring.adoc b/documentation/modules/ROOT/pages/07_spring.adoc index f29b488..5d82a01 100644 --- a/documentation/modules/ROOT/pages/07_spring.adoc +++ b/documentation/modules/ROOT/pages/07_spring.adoc @@ -61,14 +61,16 @@ Spring Data is one of the most popular Spring APIs, so let's create a Spring Dat package com.redhat.developers; import java.util.List; - import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; import org.springframework.stereotype.Repository; @Repository public interface SpringMovieRepository extends JpaRepository { - public List findByYear(String year); + @Query("select m from Movie m where year(m.releaseDate) = :year") + List findByYear(@Param("year") int year); } ---- @@ -83,7 +85,6 @@ Now let's create another REST endpoint for `Movie`, but now using the Spring Web package com.redhat.developers; import java.util.List; - import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; @@ -102,7 +103,7 @@ public class MovieController { @GetMapping public List movies(@RequestParam("year") String year) { if (year != null) { - return movieRepository.findByYear(year); + return movieRepository.findByYear(Integer.parseInt(year)); } return movieRepository.findAll(); }