add tests reflecting things in Jakarta Data TCK

Signed-off-by: Gavin King <gavin@hibernate.org>
This commit is contained in:
Gavin King 2024-04-04 10:50:41 +02:00
parent e748619dd6
commit ff0e676825
4 changed files with 14 additions and 0 deletions

View File

@ -25,6 +25,9 @@ public interface Bookshop extends CrudRepository<Book,String> {
@Query("select count(this) where this.title like ?1 order by this.isbn")
long count2(String title);
@Query("select count(this)")
long countAll();
@Query("where isbn in :isbns and type = Book")
List<Book> books(List<String> isbns);

View File

@ -14,6 +14,8 @@ import java.util.Set;
@Entity
@Table(name = "books")
public class Book {
public enum Type { Book, Magazine, Journal }
@Id
String isbn;
@ -34,6 +36,8 @@ public class Book {
int pages;
Type type;
public Book(String isbn, String title, String text) {
this.isbn = isbn;
this.title = title;

View File

@ -4,10 +4,14 @@ import jakarta.data.repository.Query;
import jakarta.data.repository.Repository;
import java.util.List;
import java.util.Set;
@Repository(dataStore = "myds")
public interface BookAuthorRepository$ extends BookAuthorRepository {
@Override
@Query("from Book where title like :title")
List<Book> findByTitleLike(String title);
@Override
@Query("from Book where type in :types")
List<Book> findByTypeIn(Set<Book.Type> types);
}

View File

@ -17,14 +17,17 @@ import jakarta.data.repository.Repository;
import jakarta.data.repository.Save;
import jakarta.data.repository.Update;
import org.hibernate.StatelessSession;
import org.hibernate.processor.test.data.namedquery.Book.Type;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Stream;
@Repository(dataStore = "myds")
public interface BookAuthorRepository {
List<Book> findByTitleLike(String title);
List<Book> findByTypeIn(Set<Type> types);
}