liveBook · Manning

JPQL

As explained in Troubleshooting Java, Second Edition

JPQL is an object-oriented query language for retrieving and manipulating persistent entities defined by the Java Persistence API.

JPQL is an object-oriented query language used with Java Persistence API entities. Spring Data JPA can define queries through repository methods or JPQL while generating SQL behind the scenes. section 6.3.2

Because the executed SQL is not visible in repository code, investigating performance requires observing the JDBC boundary. A profiler can intercept generated queries before they reach the DBMS, allowing them to be copied into a SQL client for further analysis. section 6.3.2

public interface ProductRepository 
    extends JpaRepository<Product, Integer> { 
}

A minimal Spring Data JPA repository shows why framework-generated SQL may not be directly visible in application code. section 6.3.2

Profiling a product lookup

A product endpoint returns purchased-product names through a repository called ten times. Profiling reveals two SQL queries, with the second executed only once because Hibernate optimizes execution. The captured query can then be investigated in a SQL development client. section 6.3.2

How Troubleshooting Java, Second Edition covers it

How deep it goes
Defines JPQL briefly and stops short of its grammar or query-writing rules.
Examples
Uses a product repository, a product endpoint, profiler output, and a copied SQL query examined in a SQL client.
What it assumes
Assumes familiarity with Spring Data JPA repositories, JDBC, Hibernate, and database queries.
What you can do after
Diagnose framework-generated SQL by profiling JDBC traffic and investigating captured queries in a SQL client.
How it connects
Connects JPQL with Spring Data JPA, Hibernate, JDBC, SQL, and database performance investigation.

Also explained in

Compare how 2 books explain JPQL →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Troubleshooting Java, Second Edition. The section links point to the parts of the book it draws on.