EclipseLink provides an expression framework (also known as EclipseLink Native Query Support) with which you can express queries in a database-neutral fashion as an alternative to SQL when writing queries not supported by JPQL. EclipseLink expressions offer the following advantages over SQL when you access a database:
Expressions are easier to maintain because the database is abstracted.
Changes to descriptors or database tables do not affect the querying structures in the application.
Expressions enhance readability by standardizing the
Query interface so that it looks similar to traditional Java calling conventions.
Expressions enable read queries to transparently query between two classes that share a relationship. If these classes are stored in multiple tables in the database, EclipseLink automatically generates the appropriate join statements to return information from both tables.
Expressions simplify complex operations.
EclipseLink automatically generates the appropriate SQL from the specified expression.
The expression framework lets you work with expressions, database queries, call objects, and native queries.
JPA Query Using a EclipseLink
DatabaseQuery is a query object that provides a robust API for handling a variety of database query requirements, including reading and writing at the object level and at the data level.
JPA Query Using a EclipseLink Call Object
setCall, you can define your own EclipseLink
Call to accommodate a variety of data source options, such as SQL stored procedures and stored functions.
Named Parameters in a Native Query
Using EclipseLink, you can specify a named parameter in a native query using the EclipseLink
JPQL Positional Parameters in a Native Query
Using EclipseLink, you can specify positional parameters in a native query using the Java Persistence Query Language (JPQL) positional parameter
?n convention to specify a parameter by number.
JDBC-Style Positional Parameters in a Native Query
Using EclipseLink, you can specify positional parameters in a native query using the JDBC-style positional parameter