I'm currently developing (free time project) a Java Server Faces application which uses the #JPA
(very common to do so) over EJBs (Enterprise Java Beans). When I turned on logging of SQL queries, I thought I didn't see it right. For each entity ("row" in database table) a distinct query has been issued. Means, when I have 1,000 rows, the same amount of queries are being issued.
This can become a nightmare when "only" 100 users are on the server. Does someone know how to reconfigure the JPA (I use #Payara
) to issue only one SQL query per table?
Surely I have used JPQL (Java Persistence Query Language) and no WHERE
was used there. So normally the whole table should be fetched. But this is not the case for linked tables (e.g. with @OneToOne
) where each such referenced entity is being fetched distinctly.
So is there a way to prevent this from happening? RAM is not a issue here. 16 GB are installed and data will not grow so much.