Home > Java > javaTutorial > body text

How to solve springboot jpa lazy loading problem

PHPz
Release: 2023-05-12 13:58:11
forward
1370 people have browsed it

springboot jpa delayed loading problem

In springboot, the new spring.jpa.open-in-view=true method in the configuration file of application.properties fails

After testing, There are two solutions:

1. Add

spring.jpa.properties.hibernate.enable_lazy_load_no_trans=true;
Copy after login

to the configuration file of application.properties. 2. Add the @Transactional annotation to the test method.

About springboot lazy loading

Lazy loading or lazy loading means that when the spring container starts, it does not load all the beans into the spring container, but when needed time, this object is instantiated into the container.

Advantages:

Shorten startup time

Disadvantages:

If a configuration error occurs, it will not be found when the system starts, and strict testing is required, and It is necessary to ensure that the heap space of the JVM can satisfy all beans

Lazy loading is divided into global lazy loading and local lazy loading. Global lazy loading is achieved through configuration, and local lazy loading is achieved by adding @Lazy annotation to the class

The above is the detailed content of How to solve springboot jpa lazy loading problem. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!