From 5cd6ec4b5427443dc894d035687e3b6c6d7c184d Mon Sep 17 00:00:00 2001 From: Gavin King Date: Mon, 18 Mar 2024 22:11:13 +0100 Subject: [PATCH] add more Jakarta Data test method signatures --- .../test/data/BookAuthorRepository.java | 31 +++++++++++++++++++ .../processor/test/data/eg/EgTest.java | 2 +- .../processor/test/data/eg/Library.java | 20 ++++++++++-- 3 files changed, 50 insertions(+), 3 deletions(-) diff --git a/tooling/metamodel-generator/src/jakartaData/java/org/hibernate/processor/test/data/BookAuthorRepository.java b/tooling/metamodel-generator/src/jakartaData/java/org/hibernate/processor/test/data/BookAuthorRepository.java index d0ce1f2f79..ffd96d14c3 100644 --- a/tooling/metamodel-generator/src/jakartaData/java/org/hibernate/processor/test/data/BookAuthorRepository.java +++ b/tooling/metamodel-generator/src/jakartaData/java/org/hibernate/processor/test/data/BookAuthorRepository.java @@ -18,6 +18,7 @@ import jakarta.data.repository.Save; import jakarta.data.repository.Update; import org.hibernate.StatelessSession; +import java.math.BigDecimal; import java.time.LocalDate; import java.util.List; import java.util.Optional; @@ -38,6 +39,12 @@ public interface BookAuthorRepository { @Insert void insertBooks2(Set books); + @Insert + List insertBooks3(List books); + + @Insert + Book[] insertBooks4(Book[] books); + @Find Book book(String isbn); @@ -47,6 +54,9 @@ public interface BookAuthorRepository { @Find List booksWithPages(Iterable pages); + @Find + List booksWithPages(int pages); + @Find Optional bookIfAny(String isbn); @@ -77,6 +87,9 @@ public interface BookAuthorRepository { @Find List byPubDate3(LocalDate publicationDate, Sort... order); + @Find + Stream byPubDate4(LocalDate publicationDate, Sort order); + @Find Book[] bookArrayByTitle(String title); @@ -95,6 +108,9 @@ public interface BookAuthorRepository { @Query("from Book where title = :title") Book bookWithTitle(String title); + @Query("from Book where title = :title") + Optional bookWithTitleMaybe(String title); + @Query("from Book where title like :title") List books0(String title); @@ -116,6 +132,9 @@ public interface BookAuthorRepository { @Query("select title from Book where title like :title order by isbn") String[] titles1(String title); + @Query("from Book") + Stream everyBook0(Order order); + @Query("from Book") List everyBook1(PageRequest pageRequest); @@ -154,9 +173,21 @@ public interface BookAuthorRepository { @Find List allBooksWithLotsOfSorting(Sort s1, Order order, Sort... s3); + @Query("where price < ?1 and pages > ?2") + Book[] valueBooks0(BigDecimal maxPrice, int minPages); + + @Query("where price < :maxPrice and pages > :minPages") + Book[] valueBooks1(BigDecimal maxPrice, int minPages); + + @Query("where price < :price and pages > :pages") + Book[] valueBooks2(@Param("price") BigDecimal maxPrice, @Param("pages") int minPages); + @Save Book write(Book book); + @Update + Book edit(Book book); + @Insert Iterable createAll(Iterable books); } diff --git a/tooling/metamodel-generator/src/jakartaData/java/org/hibernate/processor/test/data/eg/EgTest.java b/tooling/metamodel-generator/src/jakartaData/java/org/hibernate/processor/test/data/eg/EgTest.java index 794281ed34..af184070d4 100644 --- a/tooling/metamodel-generator/src/jakartaData/java/org/hibernate/processor/test/data/eg/EgTest.java +++ b/tooling/metamodel-generator/src/jakartaData/java/org/hibernate/processor/test/data/eg/EgTest.java @@ -18,7 +18,7 @@ import static org.hibernate.processor.test.util.TestUtil.getMetaModelSourceAsStr */ public class EgTest extends CompilationTest { @Test - @WithClasses({ Publisher.class, Author.class, Book.class, Library.class }) + @WithClasses({ Publisher.class, Author.class, Address.class, Book.class, Library.class }) public void test() { System.out.println( getMetaModelSourceAsString( Author.class ) ); System.out.println( getMetaModelSourceAsString( Book.class ) ); diff --git a/tooling/metamodel-generator/src/jakartaData/java/org/hibernate/processor/test/data/eg/Library.java b/tooling/metamodel-generator/src/jakartaData/java/org/hibernate/processor/test/data/eg/Library.java index 9e5e1b3579..dd87487b06 100644 --- a/tooling/metamodel-generator/src/jakartaData/java/org/hibernate/processor/test/data/eg/Library.java +++ b/tooling/metamodel-generator/src/jakartaData/java/org/hibernate/processor/test/data/eg/Library.java @@ -2,6 +2,7 @@ package org.hibernate.processor.test.data.eg; import jakarta.data.page.CursoredPage; import jakarta.data.page.PageRequest; +import jakarta.data.repository.By; import jakarta.data.repository.Delete; import jakarta.data.repository.Find; import jakarta.data.repository.Insert; @@ -20,6 +21,9 @@ public interface Library { @Find Book book(String isbn); + @Find + List books(@By("isbn") List isbns); + @Find Book books(String title, LocalDate publicationDate); @@ -38,14 +42,20 @@ public interface Library { @Insert void create(Book book); + @Insert + void create(Book[] book); + @Update void update(Book book); + @Update + void update(Book[] books); + @Delete void delete(Book book); - @Update - void update(Book[] books); + @Delete + void delete(Book[] book); @Save void upsert(Book book); @@ -67,4 +77,10 @@ public interface Library { @OrderBy("name") @OrderBy("address.city") //not working currently List authors(); + + @Find + List authorsByCity(@By("address.city") String city); + + @Find + List authorsByCityAndPostcode(String address_city, String address_postcode); }