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
1
vote
2 answers

Spring Data JPA + JpaSpecificationExecutor + NamedEntityGraph

I have two Entities. Parent and Child. @Entity public class Parent { @Id @Column(name = "PARENT_ID") private BigInteger id; @Column(name = "FIRST_NAME") private String firstName; @Column(name = "LAST_NAME") private…
cp392
  • 31
  • 1
  • 9
1
vote
0 answers

@Any fields and @NamedEntityGraph

I'm getting the following error when I try to create an entity graph: java.lang.IllegalArgumentException: Unable to locate Attribute with the the given name [myRelatedObject] on this ManagedType [com.example.RelatedObject] This is the…
Gonzalo Calvo
  • 304
  • 4
  • 15
1
vote
0 answers

@EntityGraph fetch Entity inside Entity

I am trying to fetch all Product Translates using EntityGraph. It works properly but it fetch all Lazy Fetched Entities also. My Product Entity: @Entity @Table(name = "product") @Where(clause = "status = 'ACTIVE'") public class Product implements…
pronomy
  • 204
  • 4
  • 15
1
vote
1 answer

Entity graph on many-to-many relation loading entities multiple times - Spring Data JPA

I have @ManyToMany relationship between two of my entities. When I try to load the parents with their children, the parents repeat in response payload. I want to solve my problem with EntityGraphs. Here is the parent with…
1
vote
0 answers

Spring data and @EntityGraph on composite primary key

I have this code : @Table(name = "contact_supplier_function") @Entity public class ContactSupplierFunctionEntity implements Serializable { private static final long serialVersionUID = 3969992836064953905L; @EmbeddedId private…
Bluntdoe
  • 11
  • 2
1
vote
0 answers

spring repository EntityGraph JoinFormula Lazy loaded even when I don't want to

I have 3 Entities, Mouvement links Agent and Poste. I can't join directly poste and agent because it depends on the date of the movement. @NamedEntityGraph(name = "graph.Agent.poste", attributeNodes = @NamedAttributeNode(value =…
ScorprocS
  • 287
  • 3
  • 14
1
vote
3 answers

Spring JPA EntityGraph fetches all lazy loaded properties

I've worked with Spring and Hibernate. Now having a look at Spring Data JPA (2.0.3) with JPA 2.2 AgencyTicketType @Entity @Table(name = "agency_ticket_type", catalog = "test") public class AgencyTicketType implements java.io.Serializable { …
Ramanujan R
  • 1,601
  • 2
  • 23
  • 43
1
vote
1 answer

Spring Data: Query DTOs with QueryDSL predicates

I am using QueryDSL to query/filter entities (Document): public interface DocumentRepository extends PagingAndSortingRepository, QueryDslPredicateExecutor Then I build QueryDSL Predicates and use method findAll to…
miran
  • 1,419
  • 1
  • 12
  • 26
1
vote
1 answer

Duplicated results by using EntityGraph in the case of OneToMany relationship

I decided to use Entity Graph capability of JPA 2.1 in my recently started project but I faced with a problem. It goes well when you extend your graph over ManyToOne relationships but for OneToMany, results get duplicated because my provider…
hyeganeh
  • 348
  • 2
  • 11
1
vote
0 answers

.ClassCastException: org.hibernate.internal.SQLQueryImpl cannot be cast to org.hibernate.internal.QueryImpl

I'm trying to fetch some Lazy collection using EntityGraph on my Entity @Entity @Table ...... @NamedEntityGraph(name = "getDetails", attributeNodes = { @NamedAttributeNode(value = "prices") }) @NamedNativeQuery(name = "MyTable.getData", query…
Oleg Kuts
  • 769
  • 1
  • 13
  • 26
1
vote
1 answer

Spring Data JPA entity graphs are not working with Spring Boot

Defined entity graph is not taken into consideration when application is based on Spring Boot. In contrary, everything works fine during JUnit tests. Domain is quite simple: books and their categories (many to many relation). Book…
Marek J
  • 1,364
  • 8
  • 18
  • 33
1
vote
0 answers

JPA entity graph: all properties except one

I have a Product entity about 30 fields. I like to use EntityGraph to fetch product list except its description that is a CLOB. I have to add 29 other properties to the EntityGraph. Is there a way to say: all properties except property A? …
Dave
  • 759
  • 2
  • 9
  • 31
1
vote
1 answer

JPA: EntityGraph and map

I use EclipseLink 2.6.3 as JPA provider. I have two entities: @Entity public class ClassA{ @Id private String uuid; private String comment; @OneToMany(fetch = FetchType.EAGER,cascade = CascadeType.ALL,mappedBy =…
Pavel_K
  • 10,748
  • 13
  • 73
  • 186
1
vote
1 answer

JPA entity graphs and pagination

In my current project we have multiple search pages in the system where we fetch a lot of data from the database to be shown in a large table element in the UI. We're using JPA for data access (our provider is Hibernate). The data for most of the…
Markus Yrjölä
  • 859
  • 1
  • 12
  • 25
0
votes
0 answers

AssertionError running SpringBoot unit test using Repository Spring JPA for entities with EntityGraph annotation

after upgraded from Java11 to Java17 some unit test has becoming failing. I'm using Java 17 locally existing VM temurin-17.jdk with Springboot 3.0.2 and Junit 5.9.2. This is the unit test failing now: public class MyServiceTests { …