search
HomeJavajavaTutorialHow to solve springboot jpa lazy loading problem

How to solve springboot jpa lazy loading problem

May 12, 2023 pm 01:58 PM
springbootjpa

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;

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!

Statement
This article is reproduced at:亿速云. If there is any infringement, please contact admin@php.cn delete

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Tools

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft