Top Description Inners Fields Constructors Methods
org.eclipse.persistence.internal.jpa.jpql

public Class JPQLQueryHelper

extends Object
Class Inheritance
Imports
java.util.ArrayList, .HashSet, .LinkedList, .List, .Set, org.eclipse.persistence.descriptors.ClassDescriptor, org.eclipse.persistence.internal.sessions.AbstractSession, org.eclipse.persistence.jpa.jpql.Assert, org.eclipse.persistence.jpa.jpql.parser.AbstractEclipseLinkTraverseChildrenVisitor, .DefaultEclipseLinkJPQLGrammar, .DeleteClause, .Expression, .FromClause, .JPQLExpression, .JPQLGrammar, .SimpleSelectStatement, .UpdateClause, org.eclipse.persistence.queries.DatabaseQuery

This helper can perform various operations over a JPQL query.
Author
Pascal Filion
Since
2.5
Version
2.5

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private JPQLGrammar
jpqlGrammar

The grammar that defines how to parse a JPQL query.

Constructor Summary

AccessConstructor and Description
public
JPQLQueryHelper()

Creates a new JPQLQueryHelper which uses the latest JPQL grammar.

public
JPQLQueryHelper(JPQLGrammar
The JPQLGrammar that will determine how to parse JPQL queries
jpqlGrammar
)

Creates a new JPQLQueryHelper.

Method Summary

Modifier and TypeMethod and Description
public List<ClassDescriptor>

Returns:

The list of descriptors used in the JPQL query or an empty list if the JPQL query is invalid or incomplete
getClassDescriptors
(CharSequence
The JPQL query used to gather the descriptors defined in the declaration clause
jpqlQuery
,
AbstractSession
The AbstractSession is used to retrieve the descriptors
session
)

Retrieves the list of descriptors corresponding to the entities used throughout the given JPQL query.

public List<ConstructorQueryMappings>

Returns:

The holder of the result
getConstructorQueryMappings
(AbstractSession
The AbstractSession is used to retrieve the mappings used in the constructor items
session
)

Retrieves the class names and the attribute names mapped to their types that are used in the constructor expressions defined in the SELECT clause.

public ConstructorQueryMappings

Returns:

The holder of the result
getConstructorQueryMappings
(AbstractSession
The AbstractSession is used to retrieve the mappings used in the constructor items
session
,
DatabaseQuery query)

Retrieves the class names and the attribute names mapped to their types that are used in the constructor expressions defined in the SELECT clause.

public JPQLGrammar

Returns:

The grammar that will determine how to parse a JPQL query
getGrammar
()

Returns the JPQL grammar that will be used to define how to parse a JPQL query.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

jpqlGrammarback to summary
private JPQLGrammar jpqlGrammar

The grammar that defines how to parse a JPQL query.

Constructor Detail

JPQLQueryHelperback to summary
public JPQLQueryHelper()

Creates a new JPQLQueryHelper which uses the latest JPQL grammar.

JPQLQueryHelperback to summary
public JPQLQueryHelper(JPQLGrammar jpqlGrammar)

Creates a new JPQLQueryHelper.

Parameters
jpqlGrammar:JPQLGrammar

The JPQLGrammar that will determine how to parse JPQL queries

Exceptions
NullPointerException:
The JPQLGrammar cannot be null

Method Detail

getClassDescriptorsback to summary
public List<ClassDescriptor> getClassDescriptors(CharSequence jpqlQuery, AbstractSession session)

Retrieves the list of descriptors corresponding to the entities used throughout the given JPQL query.

Parameters
jpqlQuery:CharSequence

The JPQL query used to gather the descriptors defined in the declaration clause

session:AbstractSession

The AbstractSession is used to retrieve the descriptors

Returns:List<ClassDescriptor>

The list of descriptors used in the JPQL query or an empty list if the JPQL query is invalid or incomplete

getConstructorQueryMappingsback to summary
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 the SELECT 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:AbstractSession

The AbstractSession is used to retrieve the mappings used in the constructor items

Returns:List<ConstructorQueryMappings>

The holder of the result

getConstructorQueryMappingsback to summary
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 the SELECT 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:AbstractSession

The AbstractSession is used to retrieve the mappings used in the constructor items

Returns:ConstructorQueryMappings

The holder of the result

getGrammarback to summary
public JPQLGrammar getGrammar()

Returns the JPQL grammar that will be used to define how to parse a JPQL query.

Returns:JPQLGrammar

The grammar that will determine how to parse a JPQL query

org.eclipse.persistence.internal.jpa.jpql back to summary

private Class JPQLQueryHelper.DescriptorCollector

extends AbstractEclipseLinkTraverseChildrenVisitor
Class Inheritance

Field Summary

Modifier and TypeField and Description
private Set<ClassDescriptor>
private JPQLQueryContext
private DeclarationResolver

Constructor Summary

AccessConstructor and Description
private
DescriptorCollector(JPQLQueryContext queryContext)

Creates a new DescriptorCollector.

Method Summary

Modifier and TypeMethod and Description
private void
public void
public void
public void
public void
Inherited from org.eclipse.persistence.jpa.jpql.parser.AbstractEclipseLinkTraverseChildrenVisitor:
visitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisit

Field Detail

descriptorsback to summary
private Set<ClassDescriptor> descriptors
queryContextback to summary
private JPQLQueryContext queryContext
resolverback to summary
private DeclarationResolver resolver

Constructor Detail

DescriptorCollectorback to summary
private DescriptorCollector(JPQLQueryContext queryContext)

Creates a new DescriptorCollector.

Method Detail

collectDescriptorsback to summary
private void collectDescriptors(Expression expression, DeclarationResolver resolver)
visitback to summary
public void visit(DeleteClause expression)

Overrides org.eclipse.persistence.jpa.jpql.parser.AnonymousExpressionVisitor.visit.

Implements org.eclipse.persistence.jpa.jpql.parser.ExpressionVisitor.visit.

Doc from org.eclipse.persistence.jpa.jpql.parser.ExpressionVisitor.visit.

Visits the DeleteClause expression.

Parameters
expression:DeleteClause

The Expression to visit

Annotations
@Override
visitback to summary
public void visit(FromClause expression)

Overrides org.eclipse.persistence.jpa.jpql.parser.AnonymousExpressionVisitor.visit.

Implements org.eclipse.persistence.jpa.jpql.parser.ExpressionVisitor.visit.

Doc from org.eclipse.persistence.jpa.jpql.parser.ExpressionVisitor.visit.

Visits the FromClause expression.

Parameters
expression:FromClause

The Expression to visit

Annotations
@Override
visitback to summary
public void visit(SimpleSelectStatement expression)

Overrides org.eclipse.persistence.jpa.jpql.parser.AnonymousExpressionVisitor.visit.

Implements org.eclipse.persistence.jpa.jpql.parser.ExpressionVisitor.visit.

Doc from org.eclipse.persistence.jpa.jpql.parser.ExpressionVisitor.visit.

Visits the SimpleSelectStatement expression.

Parameters
expression:SimpleSelectStatement

The Expression to visit

Annotations
@Override
visitback to summary
public void visit(UpdateClause expression)

Overrides org.eclipse.persistence.jpa.jpql.parser.AnonymousExpressionVisitor.visit.

Implements org.eclipse.persistence.jpa.jpql.parser.ExpressionVisitor.visit.

Doc from org.eclipse.persistence.jpa.jpql.parser.ExpressionVisitor.visit.

Visits the UpdateClause expression.

Parameters
expression:UpdateClause

The UpdateClause to visit

Annotations
@Override