add more Jakarta Data test method signatures

This commit is contained in:
Gavin King 2024-03-18 22:11:13 +01:00
parent 4bb5bc60e9
commit 5cd6ec4b54
3 changed files with 50 additions and 3 deletions

View File

@ -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<Book> books);
@Insert
List<Book> insertBooks3(List<Book> books);
@Insert
Book[] insertBooks4(Book[] books);
@Find
Book book(String isbn);
@ -47,6 +54,9 @@ public interface BookAuthorRepository {
@Find
List<Book> booksWithPages(Iterable<Integer> pages);
@Find
List<Book> booksWithPages(int pages);
@Find
Optional<Book> bookIfAny(String isbn);
@ -77,6 +87,9 @@ public interface BookAuthorRepository {
@Find
List<Book> byPubDate3(LocalDate publicationDate, Sort<? super Book>... order);
@Find
Stream<Book> byPubDate4(LocalDate publicationDate, Sort<? super Book> 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<Book> bookWithTitleMaybe(String title);
@Query("from Book where title like :title")
List<Book> 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<Book> everyBook0(Order<? super Book> order);
@Query("from Book")
List<Book> everyBook1(PageRequest<? super Book> pageRequest);
@ -154,9 +173,21 @@ public interface BookAuthorRepository {
@Find
List<Book> allBooksWithLotsOfSorting(Sort<? super Book> s1, Order<? super Book> order, Sort<? super Book>... 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<Book> createAll(Iterable<Book> books);
}

View File

@ -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 ) );

View File

@ -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<Book> books(@By("isbn") List<String> 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<Author> authors();
@Find
List<Author> authorsByCity(@By("address.city") String city);
@Find
List<Author> authorsByCityAndPostcode(String address_city, String address_postcode);
}