@LazyToOne(LazyToOneOption.NO_PROXY) relationship fields executing additional queries

Description

The problem described below only happens with to-one relationships. To-many is working fine.

I have the following @Entity in my application.

I'm using the following @Repository to look for Account.

My test endpoint contains a simple method.

When I execute this endpoint, this is what I'm seeing in the log.

As you can see, in the middle of the account name and the nationality name, there's an extra query just to select the nationality field. It means if I have 50 records, 50 additional queries got executed. May I know how I can fix this behaviour?

Below is what I used in pom.xml to activate Hibernate Bytecode Enhancer

Environment

Windows 10, Spring Boot v2.2.7, Hibernate v5.4.15.Final, `spring-data-jpa-entity-graph` v2.2.8, SQL Server, Java 8

Assignee

Unassigned

Reporter

James Tran Dung

Fix versions

None

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Affects versions

Priority

Critical
Configure