Skip to content
Advertisement

endless hibernate query in thymeleaf for classes @OneToMeny and @ManyToOne

everybody, I’ve built myself two classes that are circulating.

additive class

JavaScript

and class with types

JavaScript

when I try to display the code using thymeleaf

JavaScript

I get an endless queries to the database once from one table additive once from another additive_type, even when fetch type is marked as lazy fetch = FetchType.LAZY

How do you remedy that?

UPDATE

Unfortunately, neither @JsonIgnoreProperties nor @JsonIgnore has led to a break in the circular inquiry. I used these annotations in the rest service and it worked there. Here at thymeleaf it didn’t bring the desired effect.

Advertisement

Answer

I’ve gone over the problem by adding a class to the same table with a list of additions of this type. From the base class I threw out the reference to the list of add-ons.

Additive class and thymeleaf code without changes.

I copied the AdditiveType class to AdditiveTypeFull. I threw out a list of additions from the AdditiveType class. The service returns the class AdditiveTypeFull

JavaScript

AdditiveTypeFull class

JavaScript

I realize it’s not an elegant solution, but it works.

As if somebody knew the legal solution, I’d be happy to get used to it.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement