@Override public void emitErrorMessage(String msg) { throw new JPA2RecognitionException(msg); } }
protected QueryTree getTree() { if (queryTree == null) { try { queryTree = new QueryTree(model, query); } catch (JPA2RecognitionException e) { throw new JpqlSyntaxException(format("Errors found for input JPQL:[%s]\n%s", StringUtils.strip(query), e.getMessage())); } List<ErrorRec> errors = new ArrayList<>(queryTree.getInvalidIdVarNodes()); if (!errors.isEmpty()) { throw new JpqlSyntaxException(format("Errors found for input JPQL:[%s]", StringUtils.strip(query)), errors); } } return queryTree; }
protected QueryTree getTree() { if (queryTree == null) { try { queryTree = new QueryTree(model, query); } catch (JPA2RecognitionException e) { throw new JpqlSyntaxException(format("Errors found for input JPQL:[%s]\n%s", StringUtils.strip(query), e.getMessage())); } List<ErrorRec> errors = new ArrayList<>(queryTree.getInvalidIdVarNodes()); if (!errors.isEmpty()) { throw new JpqlSyntaxException(format("Errors found for input JPQL:[%s]", StringUtils.strip(query)), errors); } } return queryTree; }
} catch (JPA2RecognitionException e) { List<String> errorMessages = new ArrayList<>(); errorMessages.add(e.getMessage()); return new HintResponse("Query error", errorMessages);
/** * Internal method to register entity variables found in query * * @param variableName - found entity variable name * @param entity entity model */ public void addEntityVariable(String variableName, JpqlEntityModel entity) { if (variableName == null) { throw new JPA2RecognitionException("No entity variable name passed"); } if (entity == null) { throw new JPA2RecognitionException("No entity passed"); } if (entityVariableName2entity.containsKey(variableName)) throw new JPA2RecognitionException( String.format("The identification variable '%s' cannot be declared more than once", variableName)); entityVariableName2entity.put(variableName, entity); }
public QueryTree(DomainModel model, String query, boolean failOnErrors) { Preconditions.checkNotNull(query, "query is null"); String modifiedQuery = StringUtils.replaceChars(query, "\n\r\t", " "); this.model = model; this.queryString = modifiedQuery; try { this.tree = Parser.parse(modifiedQuery, failOnErrors); } catch (RecognitionException e) { throw new JPA2RecognitionException("JPA grammar recognition error", e); } this.idVarSelector = new IdVarSelector(model); new TreeVisitor().visit(tree, idVarSelector); }