Module org.eclipse.persistence.core
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 newJPQLQueryHelperwhich 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 ofdescriptorscorresponding 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 theSELECTclause.ConstructorQueryMappingsgetConstructorQueryMappings(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 theSELECTclause.JPQLGrammargetGrammar()Returns the JPQL grammar that will be used to define how to parse a JPQL query.
-
-
-
Constructor Detail
-
JPQLQueryHelper
public JPQLQueryHelper()
Creates a newJPQLQueryHelperwhich uses the latest JPQL grammar.
-
JPQLQueryHelper
public JPQLQueryHelper(JPQLGrammar jpqlGrammar)
Creates a newJPQLQueryHelper.- Parameters:
jpqlGrammar- TheJPQLGrammarthat will determine how to parse JPQL queries- Throws:
NullPointerException- TheJPQLGrammarcannot benull
-
-
Method Detail
-
getClassDescriptors
public List<ClassDescriptor> getClassDescriptors(CharSequence jpqlQuery, AbstractSession session)
Retrieves the list ofdescriptorscorresponding to the entities used throughout the given JPQL query.- Parameters:
jpqlQuery- The JPQL query used to gather the descriptors defined in the declaration clausesession- TheAbstractSessionis used to retrieve the descriptors- Returns:
- The list of
descriptorsused 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 theSELECTclause.
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- TheAbstractSessionis 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 theSELECTclause.For instance, from the following JPQL query:
SELECT new test.example.Address(a.streetName, a.zipcode) FROM Address a
The return object istest.example.Address |- BasicMapping(streetName) : String |- BasicMapping(zipcode) : int- Parameters:
session- TheAbstractSessionis 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
-
-