Skip to content

Commit 5d940bb

Browse files
This will work as soon as spring-projects/spring-data-jpa#2681 is resolved
1 parent adf5b41 commit 5d940bb

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

data-jpa/src/main/java/com/example/data/jpa/BookRepository.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
public interface BookRepository extends ListCrudRepository<Book, Long> {
2424

25-
@EntityGraph(value = "Book.authors")
25+
// @EntityGraph(value = "Book.authors")
2626
@Query("SELECT b FROM Book b WHERE b.title = :title")
2727
Book findByTitleWithNamedGraph(String title);
2828

data-jpa/src/main/java/com/example/data/jpa/CLR.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ private void entityGraph() {
7373
book.getAuthors().add(author);
7474
bookRepository.save(book);
7575

76-
Book loaded = bookRepository.findByTitleWithNamedGraph("Spring in Action");
76+
// Book loaded = bookRepository.findByTitleWithNamedGraph("Spring in Action");
77+
Book loaded = bookRepository.findByTitleWithAdHocGraph("Spring in Action");
7778
System.out.println("namedEntityGraph: " + loaded);
7879
}
7980

data-jpa/src/main/java/com/example/data/jpa/model/Book.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
import jakarta.persistence.OneToMany;
1414

1515
@Entity
16-
@NamedEntityGraph(name = "Book.authors", attributeNodes = @NamedAttributeNode("authors"))
16+
// @NamedEntityGraph(name = "Book.authors", attributeNodes =
17+
// @NamedAttributeNode("authors"))
1718
public class Book {
1819

1920
@Id

0 commit comments

Comments
 (0)