Class JPQLQueryHelper
- java.lang.Object
-
- org.eclipse.persistence.internal.jpa.jpql.JPQLQueryHelper
-
public class JPQLQueryHelper extends Object
This helper can perform various operations over a JPQL query.- Since:
- 2.5
- Version:
- 2.5
- Author:
- Pascal Filion
-
-
Constructor Summary
Constructors Constructor Description JPQLQueryHelper()
Creates a newJPQLQueryHelper
which uses the latest JPQL grammar.JPQLQueryHelper(JPQLGrammar jpqlGrammar)
Creates a newJPQLQueryHelper
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description List<ClassDescriptor>
getClassDescriptors(CharSequence jpqlQuery, AbstractSession session)
Retrieves the list ofdescriptors
corresponding to the entities used throughout the given JPQL query.List<ConstructorQueryMappings>
getConstructorQueryMappings(AbstractSession session)
Retrieves the class names and the attribute names mapped to their types that are used in the constructor expressions defined in theSELECT
clause.ConstructorQueryMappings
getConstructorQueryMappings(AbstractSession session, DatabaseQuery query)
Retrieves the class names and the attribute names mapped to their types that are used in the constructor expressions defined in theSELECT
clause.JPQLGrammar
getGrammar()
Returns the JPQL grammar that will be used to define how to parse a JPQL query.
-
-
-
Constructor Detail
-
JPQLQueryHelper
public JPQLQueryHelper()
Creates a newJPQLQueryHelper
which uses the latest JPQL grammar.
-
JPQLQueryHelper
public JPQLQueryHelper(JPQLGrammar jpqlGrammar)
Creates a newJPQLQueryHelper
.- Parameters:
jpqlGrammar
- TheJPQLGrammar
that will determine how to parse JPQL queries- Throws:
NullPointerException
- TheJPQLGrammar
cannot benull
-
-
Method Detail
-
getClassDescriptors
public List<ClassDescriptor> getClassDescriptors(CharSequence jpqlQuery, AbstractSession session)
Retrieves the list ofdescriptors
corresponding to the entities used throughout the given JPQL query.- Parameters:
jpqlQuery
- The JPQL query used to gather the descriptors defined in the declaration clausesession
- TheAbstractSession
is used to retrieve the descriptors- Returns:
- The list of
descriptors
used in the JPQL query or an empty list if the JPQL query is invalid or incomplete
-
getConstructorQueryMappings
public List<ConstructorQueryMappings> getConstructorQueryMappings(AbstractSession session)
Retrieves the class names and the attribute names mapped to their types that are used in the constructor expressions defined in theSELECT
clause.For instance, from the following JPQL query:
SELECT new test.example.Employee(e.name, e.id), new test.example.Address(a.zipcode) FROM Employee e, Address a
The return object is
|- test.example.Employee |- |- name : String |- |- id : int |- test.example.Address |- zipcode : int
- Parameters:
session
- TheAbstractSession
is used to retrieve the mappings used in the constructor items- Returns:
- The holder of the result
-
getConstructorQueryMappings
public ConstructorQueryMappings getConstructorQueryMappings(AbstractSession session, DatabaseQuery query)
Retrieves the class names and the attribute names mapped to their types that are used in the constructor expressions defined in theSELECT
clause.For instance, from the following JPQL query:
SELECT new test.example.Address(a.streetName, a.zipcode) FROM Address a
The return object is
test.example.Address |- BasicMapping(streetName) : String |- BasicMapping(zipcode) : int
- Parameters:
session
- TheAbstractSession
is used to retrieve the mappings used in the constructor items- Returns:
- The holder of the result
-
getGrammar
public JPQLGrammar getGrammar()
Returns the JPQL grammar that will be used to define how to parse a JPQL query.- Returns:
- The grammar that will determine how to parse a JPQL query
-
-