use of org.eclipse.persistence.internal.expressions.MapEntryExpression in project eclipselink by eclipse-ee4j.
the class ExpressionBuilderVisitor method visit.
@Override
public void visit(EntryExpression expression) {
// Create the expression for the collection-valued path expression
expression.getExpression().accept(this);
// Now create the ENTRY expression
MapEntryExpression entryExpression = new MapEntryExpression(queryExpression);
entryExpression.returnMapEntry();
queryExpression = entryExpression;
// Set the expression type
type[0] = Map.Entry.class;
}
use of org.eclipse.persistence.internal.expressions.MapEntryExpression in project eclipselink by eclipse-ee4j.
the class MapKeyNode method generateExpression.
/**
* INTERNAL
* Generate the a new EclipseLink TableEntryExpression for this node.
*/
@Override
public Expression generateExpression(GenerationContext context) {
Expression owningExpression = getLeft().generateExpression(context);
MapEntryExpression whereClause = new MapEntryExpression(owningExpression);
return whereClause;
}
use of org.eclipse.persistence.internal.expressions.MapEntryExpression in project eclipselink by eclipse-ee4j.
the class ConstructorReportItem method initialize.
/**
* INTERNAL:
* Looks up mapping for attribute during preExecute of ReportQuery
*/
@Override
public void initialize(ReportQuery query) throws QueryException {
int size = getReportItems().size();
List<DatabaseMapping> mappings = new ArrayList<>();
for (int index = 0; index < size; index++) {
ReportItem item = reportItems.get(index);
item.initialize(query);
mappings.add(item.getMapping());
}
setConstructorMappings(mappings);
int numberOfItems = getReportItems().size();
// Arguments may be initialized depending on how the query was constructed, so types may be undefined though.
if (getConstructorArgTypes() == null) {
setConstructorArgTypes(new Class<?>[numberOfItems]);
}
Class<?>[] constructorArgTypes = getConstructorArgTypes();
for (int index = 0; index < numberOfItems; index++) {
if (constructorArgTypes[index] == null) {
ReportItem argumentItem = getReportItems().get(index);
if (mappings.get(index) != null) {
DatabaseMapping mapping = constructorMappings.get(index);
if (argumentItem.getAttributeExpression() != null && argumentItem.getAttributeExpression().isMapEntryExpression()) {
if (((MapEntryExpression) argumentItem.getAttributeExpression()).shouldReturnMapEntry()) {
constructorArgTypes[index] = Map.Entry.class;
} else {
constructorArgTypes[index] = (Class) mapping.getContainerPolicy().getKeyType();
}
} else {
constructorArgTypes[index] = mapping.getAttributeClassification();
}
} else if (argumentItem.getResultType() != null) {
constructorArgTypes[index] = argumentItem.getResultType();
} else if (argumentItem.getDescriptor() != null) {
constructorArgTypes[index] = argumentItem.getDescriptor().getJavaClass();
} else if (argumentItem.getAttributeExpression() != null && argumentItem.getAttributeExpression().isConstantExpression()) {
constructorArgTypes[index] = ((ConstantExpression) argumentItem.getAttributeExpression()).getValue().getClass();
} else {
// Use Object.class by default.
constructorArgTypes[index] = ClassConstants.OBJECT;
}
}
}
if (getConstructor() == null) {
try {
Constructor<?> constructor = null;
if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()) {
try {
constructor = AccessController.doPrivileged(new PrivilegedGetConstructorFor<>(getResultType(), constructorArgTypes, true));
} catch (PrivilegedActionException exception) {
throw QueryException.exceptionWhileUsingConstructorExpression(exception.getException(), query);
}
} else {
constructor = PrivilegedAccessHelper.getConstructorFor(getResultType(), constructorArgTypes, true);
}
setConstructor(constructor);
} catch (NoSuchMethodException exception) {
throw QueryException.exceptionWhileUsingConstructorExpression(exception, query);
}
}
}
use of org.eclipse.persistence.internal.expressions.MapEntryExpression in project eclipselink by eclipse-ee4j.
the class Expression method mapEntry.
/**
* PUBLIC:
* Return a Map.Entry containing the key and the value from a mapping that maps to a java.util.Map
* This expression can only be used as a return value in a ReportQuery and cannot be used as part of
* the WHERE clause in any query
*
* EclipseLink: eb.get("mapAttribute").mapEntry()
*/
public Expression mapEntry() {
MapEntryExpression expression = new MapEntryExpression(this);
expression.returnMapEntry();
return expression;
}
use of org.eclipse.persistence.internal.expressions.MapEntryExpression in project eclipselink by eclipse-ee4j.
the class ExpressionBuilderVisitor method visit.
@Override
public void visit(KeyExpression expression) {
// First visit the parent Expression
expression.getExpression().accept(this);
// Now create the Expression of the KEY expression
queryExpression = new MapEntryExpression(queryExpression);
}
Aggregations