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
0 answers

NamedEntityGraph doesn't work with JoinColumn

I have two kotlin Entities, currently with the N+1 query problem for the OneToMany annotation. @Entity @NamedEntityGraph( name = "ParentEntity.children", attributeNodes = [NamedAttributeNode("children")] ) class ParentEntity( @Id …
TheJeff
  • 3,665
  • 34
  • 52
0
votes
1 answer

Using EntityGraph with SuperClasses and Embedded Attributes

I would like to use the EntityGraph Feature because of the known n+1 Problem. I have the following Entities structure: @Entity @Table(name = "customer") public class Customer extends Person { @Column(name = "foo") public String foo; …
sylo
  • 207
  • 3
  • 16
0
votes
1 answer

Exclude certain attributes with JPA @EntityGraph

I have a class called Program which contains a set of files (and other basic attributes), implemented as its own class ProgramFile, representing a multi-valued composite attribute of Program in the relational model. I'm using Spring Boot with…
0
votes
1 answer

Is @EntityGraph applied on the Select or the FROM?

I am trying to debug a n+1 query issue and I was trying to use EntityGraphs to solve it. Say I have the following query @Query("select om.organization from OrganizationMember om") And Organization has some extra fields say "attributes" Would the…
Archimedes Trajano
  • 35,625
  • 19
  • 175
  • 265
0
votes
1 answer

Using Named Entity Graphs in Eclipselink not work

I have 2 classes Collections @Entity @NamedEntityGraph( name = "cars-graph", attributeNodes = @NamedAttributeNode("cars")) public class Collections { @Id @ReturnInsert(returnOnly=true) private Long id; …
0
votes
0 answers

Is there a way to fetch a class with associated classes in a single SELECT query in Spring Data JPA?

I have two classes, A and B with a One-To-Many relationship. @Entity public class A { //some code @OneToMany(fetch = FetchType.LAZY, mappedBy = "abc") private List b; } I have a JPA Repository for A, and I observed that when I fetch an…
0
votes
1 answer

Spring Data JPA: Using @EntityGraph with EntityGraphType.LOAD doesn't join EAGER @OneToOne Relation

I've got the following entity-relations (in Kotlin): InvoiceEntity: @OneToOne(fetch = FetchType.LAZY) @JoinColumn(name = "contact") var contactEntity: ContactEntity?, ContactEntity: @OneToOne(mappedBy = "contactEntity", fetch = FetchType.EAGER) var…
0
votes
0 answers

Entity Graph for nested associations of tables in Spring JPA

There are 3 tables in my db: SalesOrderMaster SalesOrderDetail CustomerMaster I have repository class SalesOrderDetailRespository.java which has this method findAll() @EntityGraph(attributePaths = {"SalesOrderMaster"}, type =…
CrazyCoder
  • 2,194
  • 10
  • 44
  • 91
0
votes
1 answer

@EntityGraph annotation doesn't work properly?

I need to implement two different implementations for the same findAll() method by following different EntityGraphs annotations. By referencing through another StackOverflow post, I found a way to implement the same findAll() method with different…
Hasindu Dahanayake
  • 1,344
  • 2
  • 14
  • 37
0
votes
0 answers

How to load a full graph of 2 entities that are in relationship @OneToMany each other with a Join Table

I'm using Spring Boot and Spring Data and I have a problem when trying to load entities using JPA and EntityGraph. I have a Patient and Insurance entities. Each Patient can have many Insurances and each Insurance can be assigned to many patients. I…
0
votes
1 answer

Can i use hibernate string entityGraph with subgraphs useing org.springframework.data.jpa.repository.EntityGraph

I need to specify the fetching behavior of the relation entity of the root entity I want to use spring data org.springframework.data.jpa.repository.EntityGraph annotation for that end specify graph right in repository above method. but when I…
yaroslav prokipchyn
  • 472
  • 2
  • 8
  • 17
0
votes
1 answer

Unable to use @NamedEntityGraph with @ElementCollecion

I'm trying to set simple entity with NamedEntityGraph on it. Unfortunately it won't work. Could you have any ideas how to fix it? ServiceType entity has @ElementCollection of with Set of String which are simply ids of PictureModel associated with…
Miłosz
  • 17
  • 4
0
votes
1 answer

HibernateCursorItemReader and EntityGraph

I need to use HibernateCursorItemReader in a Job due to size of the Resultset, but I can't make it work with an EntityGraph to fetch some relationships eagerly. I'm using QueryProvider. Without any EntityGraph no join occurs, and the reader works…
smaudi
  • 83
  • 7
0
votes
0 answers

Hibernate with Entity Graph causing infinite loop on OneToMany

I have 2 entities: public class Foo { @OneToMany(fetch = FetchType.LAZY, mappedBy = "foo") @JsonManagedReference private List bars; } public class Bar { @ManyToOne(fetch = FetchType.LAZY) @JoinColumn("foo_id") @JsonBackReference …
0
votes
2 answers

Why does @EntityGraph not load EAGER scince Spring version 2.2.5?

Before Spring Boot 2.2.5 @EntityGraph used to load EAGER, yet after 2.2.5 I need to add EAGER to the attributePaths, for example attributePaths = {"image", "roles"} How @EntityGraph works or am i doing something wrong. The issue came up as I…