Codota is a free Java IDE plugin which you install on IntelliJ IDEA or Eclipse.
The plugin provides you with suggestions related to what methods to call for a given Java object reference. Behind the scenes, Codota uses AI to determine the most common way a given API is used. The suggestions are based on open-source projects that have been previously scanned by Codota.
JPA Criteria API
When using JPA and Hibernate, most of the time, you are either using JPQL or SQL. JPQL is useful when we want to fetch entities that we plan on modifying while native SQL allows you to take advantage of any feature offered by the underlying database.
With a JPQL or SQL query, the user has the possibility of varying the bind parameter values only. The user cannot change the query structure based on the parameters they provide from the user interface.
JPA also offers the possibility of building entity queries dynamically, meaning that we can vary the structure of the entity query based on the provided user input, and that’s exactly what Criteria API does.
Now, if you ever used the JPA Criteria API, you might have realized that the API is not very straightforward and writing a CriteriaQuery is not a trivial thing to do.
Codota can simplify the process of writing a Criteria API query as illustrated by the following screenshot:
The first 5 entries in the code suggestion pop-up are provided by Codota, and those 5 entries are the most common methods called on a Root Java Object reference.
If you want to see a demonstration of how Codota can simplify the process of writing JPA Criteria API queries, then check out the following YouTube video.
While JPA Criteria is very useful when writing dynamic entity queries, unfortunately, the API is not very suggestive. Therefore, writing a Criteria API query can take more time than necessary.
With Codota, you can write JPA Criteria queries much faster since you are given suggestions based on what’s the most likely method that you should call at any given point.
Based on my book, High-Performance Java Persistence, this workshop teaches you various data access performance optimizations from JDBC, to JPA, Hibernate and jOOQ for the major rational database systems (e.g. Oracle, SQL Server, MySQL and PostgreSQL).
The SQL Master Class for Java Developers training is aimed to level up your SQL skills with techniques such as Window Functions, recursive queries, Pivoting, JSON processing, and many other database querying features supported by Oracle, SQL Server, MySQL, or PostgreSQL.