ObjectDB Database Search
1-50 of 200 resultsJPA 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 ... and @NamedQueries Annotations The following @NamedQuery annotation defines a query named "Country.findAll | |
JPA Named Queries Annotations 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 ... , cache usage, or fetch graphs. For details and examples, see the JPA Named Queries section | |
Query Parameters in JPA because it eliminates repeated query compilations. Named Parameters (: name ) The following method retrieves ... , String name ) { TypedQuery query = em. createQuery ( "SELECT c FROM Country c WHERE c. name = : name ", Country.class); return query . setParameter (" name ", name ). getSingleResult (); } The WHERE clause | |
Setting and Tuning of JPA Queries.persistence. query .timeout", 6000); For a named query definition, use the hints element: @NamedQuery ( name ="Country.findAll", query ="SELECT c FROM Country c", hints ={@ QueryHint ( name ="jakarta ... The Query and TypedQuery interfaces define various methods for setting and tuning query execution | |
Running JPA Queries()); } Note: If you only need to print the country names , it is more efficient to use a projection query to retrieve only the names instead of the entire Country instances. Single-result query execution ... . createQuery ( "SELECT c FROM Country c WHERE c. name = 'Canada'"); Country c = (Country) query | |
JPA Criteria API Queries because of their similarity to SQL. String-based JPQL queries , such as named queries , are often preferred for simple, static ... . This differs from string-based JPQL parameters , which use a name or position. Criteria query ... The JPA Criteria API provides an alternative way to define JPA queries . It is useful for building | |
JPA Query API because it introduces the Country class to ObjectDB. Dynamic JPQL, Criteria API, and named queries In ... named queries , by using the @NamedQuery and @NamedQueries annotations. In JPA, it is a best practice to use named queries instead of dynamic queries when possible. Organization of this Section | |
JPA Queries to ObjectDB). Interface for declaring and handling named or positional query parameters. Use ... 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 | |
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 | |
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 | |
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 | |
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 ... : c. name LIKE '_r%' is TRUE for 'Brazil' and FALSE for 'Denmark' . c. name LIKE '%' is always TRUE | |
Chapter 4 - JPA Queries (JPQL / Criteria) 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 ... The Jakarta Persistence Query Language (JPQL) is an object-oriented version of SQL. Users familiar | |
SQL Queries Annotations the following annotations: Specifies a named native SQL query using the underlying database's specific SQL ... 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 | |
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 | |
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 | |
SELECT clause (JPQL / Criteria API), the following query returns country names as String instances, rather than Country objects: SELECT c. name FROM Country AS c Using path expressions , such as c. name , in query results is called ... c. name FROM Country AS c", String.class); List results = query . getResultList (); You can use | |
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 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 | |
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 | |
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 is not required to be supported for native queries . Parameters: name - parameter name Returns: parameter ... is required to be supported for criteria queries only. Parameters: name - parameter name type - type ... Query setParameter ( String name , Object value ) Bind an argument value to a named parameter | |
FROM clause (JPQL / Criteria API) By default, the name of an entity class in a JPQL query is the unqualified name of the class ... , consider the following INNER JOIN query that retrieves pairs of country names and capital names : SELECT c ... query variant: SELECT c, p. name FROM Country c LEFT OUTER JOIN c.capital p The OUTER keyword | |
jakarta.persistence.Entity.name Jakarta Persistence (JPA) Method in jakarta.persistence.Entity String name (Optional) The entity name . Defaults to the unqualified name of the entity class. This name is used to refer to the entity in queries . The name must not be a reserved literal in the Jakarta Persistence query language. Default: "" Since: Jakarta Persistence (JPA) 1.0 | |
jakarta.persistence.NamedStoredProcedureQuery.name Jakarta Persistence (JPA) Method in jakarta.persistence.NamedStoredProcedureQuery String name The name used to refer to the query with the EntityManager methods that create stored procedure query objects. Since: Jakarta Persistence (JPA) 1.0 | |
jakarta.persistence.NamedNativeQuery.name Jakarta Persistence (JPA) Method in jakarta.persistence.NamedNativeQuery String name The name used to identify the query in calls to EntityManager.createNamedQuery . Since: Jakarta Persistence (JPA) 1.0 | |
jakarta.persistence.NamedQuery.name Jakarta Persistence (JPA) Method in jakarta.persistence.NamedQuery String name (Required) The name used to identify the query in calls to EntityManager.createNamedQuery . Since: Jakarta Persistence (JPA) 1.0 | |
jakarta.persistence.SqlResultSetMapping.name Jakarta Persistence (JPA) Method in jakarta.persistence.SqlResultSetMapping String name The name given to the result set mapping, and used to refer to it in the methods of the Query and StoredProcedureQuery APIs. Since: Jakarta Persistence (JPA) 1.0 | |
jakarta.persistence.ColumnResult.name Jakarta Persistence (JPA) Method in jakarta.persistence.ColumnResult String name (Required) The name of a column in the SELECT clause of a SQL query Since: Jakarta Persistence (JPA) 1.0 | |
ORDER BY clause (JPQL / Criteria API) expressions The following query returns the names of countries with a population of at least one million, ordered by country name : SELECT c. name FROM Country c WHERE c.population 1000000 ORDER BY c. name ... The ORDER BY clause specifies the order for the query results. Any JPQL query that does not | |
GROUP BY and HAVING clauses, the following query counts the number of countries whose names start with that letter ... (DISTINCT c.currency) FROM Country c GROUP BY SUBSTRING(c. name , 1, 1); The query returns Object ... The GROUP BY clause groups query results. A JPQL query with a GROUP BY clause returns properties | |
Paths and Types in JPQL and Criteria API numbers, booleans, strings, and dates. Values of simple types are more useful in queries ... can be extended by reusing the dot ( . ) operator. For example, c.capital. name is a nested path expression that navigates from the Capital entity to its name field. A path expression can be extended | |
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 | |
JPA Persistable Types , package, or private ), and it can be either concrete or abstract. Entity class names Entity classes are represented in queries by entity names . By default, the entity name is the unqualified name of the entity class (that is, the short class name without the package name ). A different entity name | |
JPA Entity Fields 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 ... { String name ; @ManyToOne Department department; } @Entity public class Department { @OneToMany | |
jakarta.persistence.Query.getParameter(String,Class) Jakarta Persistence (JPA) Method in jakarta.persistence. Query Parameter getParameter ( String name , Class type ) Get the parameter object corresponding to the declared parameter of the given name and type. This method is required to be supported for criteria queries | |
jakarta.persistence.Query.setParameter(String,Calendar,TemporalType) - if the parameter name does not correspond to a parameter of the query or if the value argument is of incorrect ... Jakarta Persistence (JPA) Method in jakarta.persistence. Query Query setParameter ( String name , Calendar value , TemporalType temporalType ) Bind an instance | |
jakarta.persistence.Query.setParameter(String,Date,TemporalType) name does not correspond to a parameter of the query or if the value argument is of incorrect type ... Jakarta Persistence (JPA) Method in jakarta.persistence. Query Query setParameter ( String name , Date value , TemporalType temporalType ) Bind an instance | |
jakarta.persistence.Query.setParameter(String,Object): name - parameter name 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 argument is of incorrect type. Since: Jakarta Persistence (JPA) 1.0 ... Jakarta Persistence (JPA) Method in jakarta.persistence. Query Query setParameter (   | |
jakarta.persistence.StoredProcedureQuery: IllegalArgumentException - if the parameter name does not correspond to a parameter of the query or is not ... required to be supported for native queries . Inherited from Query Parameters: name - parameter name ... parameter. (Note that OUT parameters are unbound.) Inherited from Query Parameters: name - parameter | |
jakarta.persistence.Query.getParameter(String) Jakarta Persistence (JPA) Method in jakarta.persistence. Query Parameter getParameter ( String name ) Get the parameter object corresponding to the declared parameter of the given name . This method is not required to be supported for native queries . Parameters: name - parameter name | |
ObjectDB Object Database Features API . Static definition ( named queries ) in annotations (@NamedQuery) and XML. Query parameters ... , derived attributes, grouping queries and aggregate queries ) which are usually missing from Object Oriented ... entity data cache (per EntityManagerFactory). Database file page cache . Query program cache | |
Database Explorer it to view data, execute JPQL and JDOQL queries , and edit database content. Running the Explorer ... (entity and embeddable classes) in the database and their persistent fields and indexes. The Query window lets you run JPQL and JDOQL queries , as discussed later. Closing a database connection To close | |
jakarta.persistence.Query.getParameterValue(String) Jakarta Persistence (JPA) Method in jakarta.persistence. Query Object getParameterValue ( String name ) Return the input value bound to the named parameter. (Note that OUT parameters are unbound.) Parameters: name - parameter name Returns: parameter value. Throws: IllegalStateException | |
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.TypedQuery of the given name . This method is not required to be supported for native queries . Inherited from Query Parameters: name - parameter name Returns: parameter object. Throws: IllegalStateException ... parameter of the given name and type. This method is required to be supported for criteria queries | |
Database Management Settings when a database is opened and deletes it when the database is closed. The recovery file name is based on the database file name , with a $ character appended. Every transaction commit is written first ... , which modify the database. For debugging query failures, you might need to record "all" operations to reproduce |