Questions tagged [entitygraph]

In JPA Entity Graphs give the ability to specify fetch plans.

In JPA Entity Graphs give the ability to specify fetch plans.

This is useful since it allows you to customise the data that is retrieved with a query or find operation. When working with mid to large size applications is common to display data from the same entity in different and many ways. In other cases, you just want to select a smallest set of information to optimize the performance of your application.

98 questions
0
votes
1 answer

Incomplete OneToMany collections when using JPA findOne with EntityGraph

During the migration from Spring-Boot:2.7.4 to Spring-Boot:3.0.9, I notice that EntityGraphJpaSpecificationExecutor.findOne(Specification spec, EntityGraph entityGraph) does not completely resolve OneToMany collection. With spring-boot:2.7.4 this…
danielv
  • 1
  • 1
0
votes
1 answer

hibernate 6 entitygraph no longer automatically fetching nested eager fields

TL;DR Given the entity graph: Algo -> 2 (lazy) Question q1 and q2 -> (eager) abstract QuestionConfig -> child (depending on concrete type with more nested eager fields). In spring boot 2.x with hibernate 5.x the following query would not only fetch…
Stuck
  • 11,225
  • 11
  • 59
  • 104
0
votes
0 answers

How can I ignore associates on fetching data using entityGraph?

I fetch using EntityGraph with needed attributes. I have to create new endpoint to fetch data with all associates without making DTO. Is it possible and if yes how can I do this? @Query("SELECT e FROM Entity e") @EntityGraph(value =…
0
votes
0 answers

How to perform a LEFT JOIN using hibernate with dynamic value based on logged in user?

I have three entities: class Items { @Id private String id; @JsonManagedReference @OneToOne(fetch = FetchType.LAZY, mappedBy = "items", cascade = CascadeType.ALL) @NotAudited private ExternalIds externalIds; //…
0
votes
0 answers

hibernate: 'Hints not supported yet' when I try to use withHint

I encountered the n+1 problem. I am trying to use EntityGraph to solve it but I am getting "java.lang.UnsupportedOperationException: Hints not supported yet". i also tried to use session.setBatchSize(20) with no help. I would appreciate any hint …
gdgd
  • 11
  • 3
0
votes
1 answer

Can't achieve proper behavior of Paging in Spring when using EntityGraph

For last days I'm struggling with simple thing (I thought it should be simple). What I want to achieve: Create an endpoint that will respond with page of products entities. Product entities need to have category and pictures metadata which are…
Miłosz
  • 17
  • 4
0
votes
0 answers

Spring JPA join fetch with condition not working

I have an Entity that as has 1 @OneToOne (as long as there is an additional condition on the join). So I must use a join column and a condition of the join to return 1 record for this property! MySQL and latest versions on everything else involved…
0
votes
0 answers

Spring Data EntityGraph not used when sorting

I'm using Spring Data 2.6.9 to access records in a Sybase database from the following model. @Entity public class MyRecord { private String code; private String name; @OneToMany(mappedBy = "code") private Set
Schumi77
  • 1
  • 2
0
votes
0 answers

Hibernate makes additional query with @NamedEntityGraph

I have next database diagram: As you can see, tables have not foreign keys between themselves. My entities look like this: @Entity @NamedEntityGraph(name = "test", attributeNodes = [ NamedAttributeNode("room"), …
Eugene
  • 55
  • 1
  • 7
0
votes
1 answer

Why is EntityGraph not working with DataJpaTest?

Hey today i found out that my Repository-Test runs perfectly fine when i use the @SpringBootTest-Annotation. But when i switch it to @DataJpaTest-Annotation, my @OneToMany-Annotated Collection of child elements is null. Here an…
0
votes
0 answers

JPA, @ManyToMany, Pageable and performance concerns

I have two entities linked by a @ManyToMany association. Let's say Text and Country. So in my Text entity, I have: @ManyToMany(fetch = FetchType.LAZY) private Set countries = new HashSet<>(); I want to perform a paginated query that…
Clément Picou
  • 4,011
  • 2
  • 15
  • 18
0
votes
0 answers

Jpa Entity Graph usage in JPARepository and EntityManager leads to different results

I'm working on explore applications of Entity Graphs. When I tried to create few graphs via @NamedEntityGraphs for one entity I figured out, that for each graph I needed a separate method in my repository. So I decided to load data with help of…
0
votes
0 answers

JPA getResultStream() vs getResultList()

I have a method that executes a query: EntityGraph fetch = em.createEntityGraph(TypeA.class); Subgraph fetchTypeB = fetch.addSubgraph("typeB", TypeB.class); fetchTypeB.addSubgraph("typeC", TypeC.class); Set result =…
syydi
  • 119
  • 2
  • 13
0
votes
1 answer

Spring boot JPA - EntityGraph - cross join to left outer join

I have some classes, performing some queries with Entity Graph. The code is generating a cross join ... that I would like to change to left outer join. Is this possible ? So I got a this Classes @Table(schema = "public", name = "parent") public…
JPG
  • 750
  • 2
  • 8
  • 23
0
votes
0 answers

How to use EntityGraph

I am working to resolve N+1 (actually more like 10N+1) issues with reports being generated through one of our apps, and i am trying to limit what data is loaded by hibernate (5.3.20.Final) and came across EntityGraph's. My understanding is that i…
Bend
  • 304
  • 1
  • 2
  • 15