use of com.haulmont.cuba.core.sys.jpql.model.VirtualJpqlEntityModel in project cuba by cuba-platform.
the class EntityReferenceInferer method infer.
public EntityReference infer(QueryTreeTransformer queryAnalyzer) {
String entityVariableNameInQuery = queryAnalyzer.getRootEntityVariableName(entityName);
if (entityVariableNameInQuery != null) {
return new VariableEntityReference(entityName, entityVariableNameInQuery);
}
PathNode path = queryAnalyzer.getSelectedPathNode();
JpqlEntityModel entity = queryAnalyzer.getSelectedEntity(path);
if (!(entity instanceof VirtualJpqlEntityModel) && entity.getName().equals(entityName)) {
JpqlEntityModel pathStartingEntity = queryAnalyzer.getRootQueryVariableContext().getEntityByVariableName(path.getEntityVariableName());
return new PathEntityReference(path, pathStartingEntity.getName());
}
throw new RuntimeException(String.format("No variable or selected field of entity %s found in query", entityName));
}
Aggregations