I have a Java Spring Boot application with the following entities related to the below exception
SProduct
@Entity
@Table(
name =
It seems like you are loading huge amount of data in your application.
The method
FBT findByMainProductAndCollection(SProduct mainProduct,Date collection);
will load all the matching data. But you only need count try the query that exactly return count of data instead of all the data.
One way to do is using the query you mentioned and other way is
Long countByMainProductAndCollection(SProduct mainProduct, Date collection);
Or
Boolean existsByMainProductAndCollection(SProduct mainProduct, Date collection)