All lazy loads are triggered after the spring-data-jpa table entity is serialized.

< H2 > demand < / H2 >
what I want to do is to trigger (.size) lazily load all the data of the associated table when needed, do not load the data of the associated table when not needed, and do whatever I want.
< H2 > question < / H2 >

my table entity has many one-to-many, one-to-one relationships

user is one side (maintenance side specified by mappedBy)
order is multi-terminal

-sharp ordersuser,jackson.userorders@JsonIgnore
{
    user: {
        name: xxx,
        age: xxx,
    }
    orders: [
        id: xxxx,
        date: xxx
    ]
}
< H2 > the solution that comes to mind < / H2 >

add a conversion class to convert entities to map,list and then from jackson to json to return to the front end (a pile of compatibility problems and business problems)
spring data rest the control layer can return json to the front end that does not trigger lazy loading. (still does not change the status quo)

< H2 > I hope < / H2 >

there are better and more perfect ways.


does anyone know?

Menu