ObjectDB Database Search

1-50 of 200 results

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  ... Result ordering is represented by: Specifies an ordering on a query expression, supporting

Setting and Tuning of JPA Queries

let you define a result window, which is a portion of a large query result list. The setFirstResult ... for a specific page: List results = query . setFirstResult (pageIx * pageSize) . setMaxResults (pageSize ... to all result objects that the query retrieves. For example, the following code sets a pessimistic WRITE

Running JPA Queries

when exactly one result object is expected. Query .getResultList () : Use in any other case ... Country c", Country.class); List results = query . getResultList (); Both the Query and TypedQuery ... . createQuery ("SELECT c FROM Country c"); List results = query . getResultList (); Casting

JPA Criteria API Queries

variable. Finally, the range variable, c , is used in the SELECT clause as the query's result ... , which you can then execute: TypedQuery query = em. createQuery (q); List results = query . getResultList ... ); List results = query . getResultList (); Because both types of queries are ultimately represented by

Query Parameters in JPA

with different parameter values to retrieve different results . Executing the same query multiple times ... filters the query results to Country objects whose name field is equal to :name . The :name identifier ... has several drawbacks. First, the query is not reusable. Different literal values result in different query

JPA Named Queries

literals dynamically into the query string, which results in more efficient queries . @NamedQuery ... takes a query name and a result type and returns a TypedQuery instance: TypedQuery query = em. createNamedQuery ("Country.findAll", Country.class); List results = query . getResultList

JPA Query API

result type is unknown or when a query returns polymorphic results whose lowest common denominator ... interface makes it easier to run queries and process results in a type-safe manner. Building queries ... . Because the result type is known in this case (the query returns only Country objects), a TypedQuery

JPA Queries

for queries where the result type is known. It is preferred over the legacy Query interface ... 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

SQL Queries Annotations

the results of native SQL queries to entities or scalar values using these annotations: Defines how the result set of a native query maps to entities, scalar values, or constructor results . Groups ... to entity fields or scalar types with these detailed annotations: Maps a native query result to a specific

JPA Criteria Queries

the result type of a selection query . It is extended by CriteriaQuery to support the definition ... 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 

JPA Query Structure (JPQL / Criteria)

the database. The SELECT clause defines the query results . The query above returns every Country ... 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

JPA Criteria Query Expressions

;to allow using expression as query results . A boolean expression used to define restrictions in ... 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

JPA Named Queries Annotations

instances of the following interface: Represents a named query , including its name, result type, and hints ... 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

Numbers in JPQL and Criteria Queries

Numeric values can appear in JPQL queries in several forms: As numeric literals , such as 123 ... numeric promotion principles. For example, the result of a binary arithmetic operation on an int value ... of a numeric argument. The result is always a positive number or zero. For example: ABS(-5) evaluates to 5

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 that navigate to persistent string fields. As the results of predefined JPQL string manipulation 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 ... the results of predefined JPQL functions that return the current date and time. Current date and time ... when the query is executed: CURRENT_DATE : Returns the current date as a java.sql.Date instance. CURRENT_TIME

SELECT clause (JPQL / Criteria API)

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 expression in SELECT clauses. Specifying the required query results more precisely can improve

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

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

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

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

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

. Since: Jakarta Persistence (JPA) 3.2 int getFirstResult () The position of the first result the query object ... : position of the first result . Since: Jakarta Persistence (JPA) 2.0 The Running JPA Queries article ... int getMaxResults () The maximum number of results the query object was set to retrieve. Returns

FROM clause (JPQL / Criteria API)

) is not part of any iterated pair and is therefore excluded from the query results . INNER JOIN ... performance problems. For example, consider the following query execution and result iteration: TypedQuery query = em. createQuery ("SELECT c FROM Country c", Country.class); List results = query

ORDER BY clause (JPQL / Criteria API)

The ORDER BY clause specifies the order for the query results . Any JPQL query that does not ... expressions is vendor-dependent. Query results can also be sorted by multiple expressions. The first ... results for which the preceding expressions produce identical values. The following query returns Country

GROUP BY and HAVING clauses

The GROUP BY clause groups query results . A JPQL query with a GROUP BY clause returns properties of the resulting groups instead of individual objects and fields. In the query execution order ... . When a query includes a GROUP BY clause, the database objects (or tuples) that result from the FROM clause

Database Explorer

the query program and result caches. Click the Execute button to run the query . If the query is valid, the results open in a default viewer ( Tree window by default). The query window then displays the size of the result collection and the query execution time. If the query compilation fails

ObjectDB Object Database Features

(for repeating queries with different arguments). Query result cache (for repeating queries ... for efficient reuse of one query in multiple executions. Result range settings (first, max) - for paging ... , derived attributes, grouping queries and aggregate queries ) which are usually missing from Object Oriented

jakarta.persistence.StoredProcedureQuery

procedure query , followed by getUpdateCount . The results of executeUpdate ... with the query . In the simplest case, where results are returned only via INOUT and OUT parameters ... to result set. Throws: PersistenceException - if the query execution exceeds the query timeout value set

Database Management Settings

for the two query cache mechanisms that ObjectDB manages: The results attribute specifies the size of the query result cache. Caching results is useful for recurring queries with identical arguments. As ... . Therefore, caching programs is less efficient than caching results . However, cached query programs

JPA Criteria FROM and JOIN

variables for iterating over data in the database that may be relevant to the query results . Query ... ;with query results .  The following interfaces manage fetch operations within the Criteria API ... over the attribute values. Unlike a standard join, these values cannot be used in the query results or in

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.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 ... is rolled back. NonUniqueResultException - if more than one result . QueryTimeoutException - if the query

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 more than one result . QueryTimeoutException - if the query execution exceeds the query timeout

WHERE clause (JPQL / Criteria API)

to the SELECT clause to be collected as query results , the WHERE clause acts as a filter. The boolean ... and collected as query results . WHERE predicate and indexes Formally, the WHERE clause functions as a filter ... for retrieving a specific subset of objects from the database. How a WHERE clause works The following query

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 an empty list if there are no results . Throws: IllegalStateException - if called for a Jakarta Persistence

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

Paths and Types in JPQL and Criteria API

identification variables and SELECT result variables. Parameters : Instances of these classes that are assigned ... numbers, booleans, strings, and dates. Values of simple types are more useful in queries ... to the associated Capital entity. A path expression whose result is a user-defined persistent class

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

jakarta.persistence.Query.getFirstResult()

Jakarta Persistence (JPA) Method in jakarta.persistence. Query int getFirstResult() The position of the first result the query object was set to retrieve. Returns 0 if setFirstResult was not applied to the query object. Returns: position of the first result . Since: Jakarta Persistence (JPA) 2.0

Logical Operators in JPQL and Criteria API

Logical operators in JPQL and JPA criteria queries combine simple Boolean expressions to form ... , while Java uses its own notation, which is also used by the JDO Query Language (JDOQL). ObjectDB supports both notations. Binary AND (&&) operator The following query retrieves countries whose population

jakarta.persistence.Query.setMaxResults(int)

Jakarta Persistence (JPA) Method in jakarta.persistence. Query Query setMaxResults (    int maxResult ) Set the maximum number of results to retrieve. Parameters: maxResult - maximum number of results to retrieve Returns: the same query instance. Throws: IllegalArgumentException

jakarta.persistence.Query.setFirstResult(int)

Jakarta Persistence (JPA) Method in jakarta.persistence. Query Query setFirstResult (    int startPosition ) Set the position of the first result to retrieve. Parameters: startPosition - position of the first result , numbered from 0 Returns: the same query instance. Throws

jakarta.persistence.TypedQuery

Jakarta Persistence (JPA) Interface jakarta.persistence.TypedQuery Type Parameters: - query result ... result the query object was set to retrieve. Returns 0 if setFirstResult was not applied to the query object. Inherited from Query Returns: position of the first result . Since: Jakarta Persistence (JPA

jakarta.persistence.criteria.CriteriaQuery

query results are eliminated. A true value will cause duplicates to be eliminated. A false value ... must be eliminated from the query result or whether they must be retained Returns: the modified query ... predicate. Since: Jakarta Persistence (JPA) 1.0 Class getResultType () Return the result type of the query

JPA Exceptions

locking wait times. Query exceptions Exceptions specific to query execution and result retrieval: Thrown by Query .getSingleResult() when the query returns no results . Thrown by Query .getSingleResult() when the query returns more than one result . Thrown when a query exceeds the specified timeout limit

JPA Entity Fields

this case, the employees field is populated with the results of the following query : SELECT e FROM ... an automatic query when the entity is retrieved. Note : Navigation through inverse fields is much less efficient than navigation through ordinary persistent fields because it requires running queries

jakarta.persistence.EntityManager

must also be flushed before execution of any query whose result set would be affected by unflushed modifications ... result Returns: the new query instance. Throws: IllegalArgumentException - if a query has not been defined with the given name or if the query string is found to be invalid or if the query result