ObjectDB Database Search
1-50 of 200 resultsJPA Criteria API Queries The JPA Criteria API provides an alternative way to define JPA queries . It is useful for building dynamic queries whose structure is known only at runtime. JPA Criteria API vs. JPQL JPQL queries are defined as strings, similar to SQL. In contrast, JPA Criteria queries are defined by instantiating | |
Setting and Tuning of JPA Queries The Query and TypedQuery interfaces define various methods for setting and tuning query execution . To take effect, you must invoke these methods before running a query with getResultList or ... let you define a result window, which is a portion of a large query result list. The setFirstResult | |
Query Parameters in JPA Query parameters enable you to define reusable queries . You can execute these queries with different parameter values to retrieve different results. Executing the same query multiple times with different parameter values is more efficient than using a new query string for each execution | |
Running JPA Queries The Query interface defines two methods for running SELECT queries : Query .getSingleResult () : Use when exactly one result object is expected. Query .getResultList () : Use in any other case ... addition, the Query interface defines a method for running DELETE and UPDATE queries : Query | |
JPA Named Queries A named query is a statically defined query with a predefined, unchangeable query string. Using named queries instead of dynamic queries can improve code organization by separating JPQL query strings from Java code. This practice also enforces the use of query parameters instead of embedding | |
JPA Query API Jakarta Persistence (JPA) represents queries with two interfaces: the Query interface, which was the only query interface in JPA 1, and the TypedQuery interface, which was introduced in JPA 2. The TypedQuery interface extends the Query interface. Use the Query interface primarily when the query | |
JPA Queries Jakarta Persistence provides powerful APIs for executing database queries using JPQL strings or the programmatic Criteria API. These interfaces support both static and dynamic query construction with full type safety. General query objects Execute SELECT, UPDATE and DELETE queries in JPA using | |
JPA Criteria Queries to string-based JPQL for constructing dynamic queries , ensuring compile-time safety and facilitating ... queries : Criteria Queries Hierarchy in Jakarta Persistence (JPA) 3.2 Instances of  ... of CriteriaBuilder as mutable empty objects, and then defined using setter methods. All query types (SELECT | |
JPA Query Structure (JPQL / Criteria) The syntax of the Jakarta Persistence Query Language (JPQL) is similar to SQL. This is a key advantage because SQL is a powerful query language, and many developers are already familiar ... operates on Java classes and objects. For example, a JPQL query can retrieve entities, unlike SQL | |
DELETE Queries in JPA/JPQL operation. Apply changes to the database by calling the commit method. JPQL DELETE queries provide an alternative way to delete entities. Unlike SELECT queries , which retrieve data from the database, DELETE queries remove specified entities from the database. Using a DELETE query to remove entities | |
UPDATE SET Queries in JPA/JPQL. Apply the changes to the database by calling the commit method. JPQL UPDATE queries provide an alternative way to update entities. Unlike SELECT queries , which retrieve data, UPDATE queries modify specified entities directly in the database without retrieving them first. Using an UPDATE query | |
JPA Criteria Query Expressions Jakarta Persistence (JPA) Criteria API uses a hierarchy of interfaces to model query conditions and selections, enabling the construction of dynamic, type-safe queries . These interfaces represent the building blocks for defining query logic programmatically. The hierarchy of the expression | |
JPA Named Queries Annotations Jakarta Persistence (JPA) provides annotations to define static, reusable queries at the class level, separating query logic from business code. Query definitions Declare named queries using the following annotations: Specifies a static, named query in the Jakarta Persistence Query Language (JPQL | |
Chapter 4 - JPA Queries (JPQL / Criteria) The Jakarta Persistence Query Language (JPQL) is an object-oriented version of SQL. Users familiar ... and the Jakarta Persistence (JPA) Criteria Query API, which provides an alternative way to build queries in JPA. The first section describes the JPA API for running dynamic and static (named) queries | |
SQL Queries Annotations Jakarta Persistence (JPA) provides a set of annotations to define and map native SQL queries when the standard Java Persistence Query Language (JPQL) is insufficient. While ObjectDB focuses on JPQL ... databases through specific SQL dialects. Native query definitions Define raw SQL queries using | |
JPA Query Expressions (JPQL / Criteria) JPQL and criteria queries are built on query expressions. Every query consists of clauses ... Criteria API expressions. Atomic expressions The atomic query expressions are: JPQL / Criteria Variables JPQL / Criteria Parameters JPQL / Criteria Literals Every query expression consists | |
Strings in JPQL and Criteria Queries String values can appear in JPQL queries in several forms: As string literals , for example, 'abc' and '' . As parameters when string values are passed as query arguments. As path expressions ... . Criteria query string expressions Query String Expressions The JPQL string operators and functions | |
Date and Time in JPQL and Criteria Queries Date and time expressions can appear in JPQL queries in the following ways: As date and time ... when the query is executed: CURRENT_DATE : Returns the current date as a java.sql.Date instance. CURRENT_TIME ... . Date and time in criteria queries The CriteriaBuilder interface provides three factory methods | |
JPA Criteria Query Selection and Results The JPA Criteria API provides type-safe interfaces for defining query result expressions ... a single query result (result set row) and provides methods for obtaining the elements of  ... class). For more information, see the SELECT in Criteria Queries section. ORDER BY clause elements | |
Collections in JPQL and Criteria Queries Collections can appear in JPQL queries in the following ways: As parameters when a collection ... to check other collections, such as a collection passed as a query parameter. For example: 'English' IN ... are synonyms. Criteria query collection expressions The JPQL collection operators and functions | |
Literals in JPQL and Criteria Queries type literals (for example, Country ). Use JPQL literals sparingly. Queries that use parameters ... times with different parameter values. Embed literals in JPQL queries only when a single, constant ... '} . For example: {ts '2020-01-03 13:59:59'} Enum literals Enum literals in JPQL queries use the standard Java | |
Numbers in JPQL and Criteria Queries Numeric values can appear in JPQL queries in several forms: As numeric literals , such as 123 ... type and always returns a double value. Criteria query arithmetic expressions JPQL arithmetic operators and functions (which are described above) are available also as JPA criteria query expressions | |
JPA Criteria Query Date/Time Extraction Jakarta Persistence criteria queries use the following interfaces and enums to extract temporal components like year, month, or hour from date and time values. TemporalField # Base interface ... a criteria query specify the enum value that represents that component as the first argument of  | |
jakarta.persistence.Query Jakarta Persistence (JPA) Interface jakarta.persistence. Query Interface used to control query ... Chapter 4 - JPA Queries (JPQL / Criteria) explains how to use Query . Public Instance Methods int ... . Throws: IllegalStateException - if called for a Jakarta Persistence query language SELECT | |
FROM clause (JPQL / Criteria API) The FROM clause declares query identification variables for iterating over objects in the database. A query identification variable is similar to a variable in a Java enhanced for loop because both are used to iterate over objects. Range variables Range variables are query identification variables | |
SELECT clause (JPQL / Criteria API) query returns Country objects, which then become managed by the EntityManager instance em : TypedQuery query = em. createQuery ("SELECT c FROM Country c", Country.class); List results = query ... for deletion , and so on. Query results are not limited to entities. You can use almost any valid JPQL | |
jakarta.persistence.EntityManagerFactory.addNamedQuery(String,Query) ( String name , Query query ) Define the query , typed query , or stored procedure query as a named query such that future query objects can be created from it using ... of the query object (except for actual parameter binding) in effect when the named query is added | |
jakarta.persistence.Query.setLockMode(LockModeType) Jakarta Persistence (JPA) Method in jakarta.persistence. Query Query setLockMode ( LockModeType lockMode ) Set the lock mode type to be used for the query execution. Parameters: lockMode - lock mode Returns: the same query instance. Throws: IllegalStateException - if the query is found | |
jakarta.persistence.Query.getResultList() Jakarta Persistence (JPA) Method in jakarta.persistence. Query List getResultList() Execute a SELECT query and return the query results as an untyped List . Returns: a list of the results, or ... query language UPDATE or DELETE statement. PessimisticLockException - if pessimistic locking fails | |
jakarta.persistence.Query.getResultStream() Jakarta Persistence (JPA) Method in jakarta.persistence. Query Stream getResultStream() Execute a SELECT query and return the query results as an untyped Stream . By default, this method delegates ... if there are no results. Throws: IllegalStateException - if called for a Jakarta Persistence query language UPDATE or | |
jakarta.persistence.Query.getLockMode() Jakarta Persistence (JPA) Method in jakarta.persistence. Query LockModeType getLockMode() Get the current lock mode for the query . Returns null if a lock mode has not been set on the query object. Returns: lock mode. Throws: IllegalStateException - if the query is found not to be a Jakarta | |
jakarta.persistence.Query.getSingleResultOrNull() Jakarta Persistence (JPA) Method in jakarta.persistence. Query Object getSingleResultOrNull() Execute a SELECT query that returns a single untyped result. Returns: the result, or null if there is no result. Throws: IllegalStateException - if called for a Jakarta Persistence query language UPDATE or | |
jakarta.persistence.Query.getSingleResult() Jakarta Persistence (JPA) Method in jakarta.persistence. Query Object getSingleResult() Execute a SELECT query that returns a single untyped result. Returns: the result. Throws: IllegalStateException - if called for a Jakarta Persistence query language UPDATE or DELETE statement | |
jakarta.persistence.Query.executeUpdate() Jakarta Persistence (JPA) Method in jakarta.persistence. Query int executeUpdate() Execute ... : IllegalStateException - if called for a Jakarta Persistence query language SELECT statement or for a criteria query . PersistenceException - if the query execution exceeds the query timeout value set | |
jakarta.persistence.QueryTimeoutException.QueryTimeoutException(Query) Jakarta Persistence (JPA) Constructor in jakarta.persistence.QueryTimeoutException QueryTimeoutException ( Query query ) Constructs a new QueryTimeoutException exception with the specified query . Parameters: query - the query . Since: Jakarta Persistence (JPA) 1.0 | |
jakarta.persistence.QueryTimeoutException.QueryTimeoutException(String,Throwable,Query) QueryTimeoutException ( String message , Throwable cause , Query query ) Constructs a new QueryTimeoutException exception with the specified detail message, cause, and query . Parameters: cause - the cause. message - the detail message. query - the query . Since: Jakarta Persistence (JPA) 1.0 | |
jakarta.persistence.Query.getParameters() Jakarta Persistence (JPA) Method in jakarta.persistence. Query Set getParameters() Get the parameter objects corresponding to the declared parameters of the query . Returns empty set if the query has no parameters. This method is not required to be supported for native queries . Returns: set | |
jakarta.persistence.Query.getParameter(String,Class) Jakarta Persistence (JPA) Method in jakarta.persistence. Query Parameter getParameter (   ... parameter of the given name and type. This method is required to be supported for criteria queries ... : IllegalStateException - if invoked on a native query or Jakarta Persistence query language query | |
jakarta.persistence.Query.setFlushMode(FlushModeType) Jakarta Persistence (JPA) Method in jakarta.persistence. Query Query setFlushMode ( FlushModeType flushMode ) Set the flush mode type to be used for the query execution. The flush mode type applies to the query regardless of the flush mode type in use for the entity manager. Parameters | |
jakarta.persistence.Query.setTimeout(Integer) Jakarta Persistence (JPA) Method in jakarta.persistence. Query Query setTimeout ( Integer timeout ) Set the query timeout, in milliseconds. This is a hint, and is an alternative to setting the hint jakarta.persistence. query .timeout . Parameters: timeout - the timeout, in milliseconds | |
jakarta.persistence.Query.setHint(String,Object) Jakarta Persistence (JPA) Method in jakarta.persistence. Query Query setHint ( String hintName , Object value ) Set a query property or hint. The hints elements may be used to specify query properties and hints. Properties defined by this specification must be observed by | |
jakarta.persistence.Query.setParameter(int,Date,TemporalType) Jakarta Persistence (JPA) Method in jakarta.persistence. Query Query setParameter (   ... - parameter value Returns: the same query instance. Throws: IllegalArgumentException - if position does not correspond to a positional parameter of the query or if the value argument is of incorrect | |
jakarta.persistence.Query.setParameter(String,Calendar,TemporalType) Jakarta Persistence (JPA) Method in jakarta.persistence. Query Query setParameter (   ... value - parameter value Returns: the same query instance. Throws: IllegalArgumentException - if the parameter name does not correspond to a parameter of the query or if the value argument is of incorrect | |
jakarta.persistence.Query.setParameter(String,Date,TemporalType) Jakarta Persistence (JPA) Method in jakarta.persistence. Query Query setParameter (   ... - parameter value Returns: the same query instance. Throws: IllegalArgumentException - if the parameter name does not correspond to a parameter of the query or if the value argument is of incorrect type | |
jakarta.persistence.Query.setParameter(int,Object) Jakarta Persistence (JPA) Method in jakarta.persistence. Query Query setParameter (   ... . Parameters: position - position value - parameter value Returns: the same query instance. Throws: IllegalArgumentException - if position does not correspond to a positional parameter of the query or | |
jakarta.persistence.Query.setParameter(int,Calendar,TemporalType) Jakarta Persistence (JPA) Method in jakarta.persistence. Query Query setParameter (   ... value - parameter value Returns: the same query instance. Throws: IllegalArgumentException - if position does not correspond to a positional parameter of the query or if the value argument | |
jakarta.persistence.Query.getParameter(int,Class) Jakarta Persistence (JPA) Method in jakarta.persistence. Query Parameter getParameter ( int position , Class type ) Get the parameter object corresponding to the declared ... : IllegalStateException - if invoked on a native query or Jakarta Persistence query language query | |
jakarta.persistence.Query.setCacheRetrieveMode(CacheRetrieveMode) Jakarta Persistence (JPA) Method in jakarta.persistence. Query Query setCacheRetrieveMode (   ... during query execution. This cache retrieval mode overrides the cache retrieve mode in use by the entity manager. Parameters: cacheRetrieveMode - cache retrieval mode Returns: the same query instance. Since: Jakarta Persistence (JPA) 3.2 | |
jakarta.persistence.Query.setCacheStoreMode(CacheStoreMode) Jakarta Persistence (JPA) Method in jakarta.persistence. Query Query setCacheStoreMode ( CacheStoreMode cacheStoreMode ) Set the cache storage mode that is in effect during query ... . Parameters: cacheStoreMode - cache storage mode Returns: the same query instance. Since: Jakarta Persistence (JPA) 3.2 | |
jakarta.persistence.Query.getMaxResults() Jakarta Persistence (JPA) Method in jakarta.persistence. Query int getMaxResults() The maximum number of results the query object was set to retrieve. Returns Integer.java.lang.Integer/MAX_VALUE if Query .setMaxResults was not applied to the query object. Returns: maximum number of results. Since: Jakarta Persistence (JPA) 2.0 |