if (fieldName == null || fieldName.isEmpty()) throw new JPQLParseException( "You have not given any column name after . ,Column name should not be empty"); throw new JPQLParseException("Bad query format"); throw new JPQLParseException("Bad query format");
Assert.assertTrue(jpqlpe.getMessage().startsWith("Bad query format")); Assert.assertTrue(jpqlpe.getMessage().startsWith("Bad query format")); Assert.assertTrue(jpqlpe.getMessage().startsWith( "You have not given any column name after . ,Column name should not be empty"));
e.getMessage()); e.getMessage()); e.getMessage()); e.getMessage()); Assert.assertEquals("invalid column nameABC", e.getMessage()); Assert.assertTrue(e.getMessage().startsWith("Invalid sort order provided:ASCENDING"));
} catch (IllegalArgumentException e) { logger.error("Error while parsing order by clause:"); throw new JPQLParseException("Invalid sort order provided:" + nextOrder);
e.getMessage()); e.getMessage()); e.getMessage()); e.getMessage());
@Test public void testJPQLParseException() { JPQLParseException exception = new JPQLParseException(); Assert.assertNotNull(exception); exception = new JPQLParseException("Error with string"); Assert.assertNotNull(exception); exception = new JPQLParseException(new RuntimeException()); Assert.assertNotNull(exception); }
throw new JPQLParseException("No column found by this name : " + property + ". Check your query.");
/** * Compile group. */ private void compileGroup() { GroupByClause groupByClause = null; if (query.isSelectStatement()) { groupByClause = (GroupByClause) query.getSelectStatement().getGroupByClause(); } // content cannot be empty if (groupByClause == null || groupByClause.toActualText().length() == 0) { throw new JPQLParseException("keyword without value: GROUP BY"); } groupingClause = groupByClause.toActualText(); }
/** * Compile having. */ private void compileHaving() { HavingClause havingClause = null; if (query.isSelectStatement()) { havingClause = (HavingClause) query.getSelectStatement().getHavingClause(); } // content cannot be empty if (havingClause == null || havingClause.toActualText().length() == 0) { throw new JPQLParseException("keyword without value: HAVING"); } if (groupingClause != null) { groupingClause = groupingClause.trim() + havingClause.toActualText(); } else { groupingClause = havingClause.toActualText(); } }
throw new JPQLParseException("Bad query format FROM clause is mandatory for SELECT queries"); throw new JPQLParseException("Bad query format: " + from + ". Identification variable is mandatory in FROM clause for SELECT queries");
/** * Compile order. */ private void compileOrder() { OrderByClause orderByClause = null; if (query.isSelectStatement()) { orderByClause = (OrderByClause) query.getSelectStatement().getOrderByClause(); } if (orderByClause == null || !orderByClause.hasOrderByItems()) { throw new JPQLParseException("keyword without value: ORDER BY"); } query.setOrdering(orderByClause.getOrderByItems().toActualText()); } }
/** * Sets the kundera query type object. */ private void setKunderaQueryTypeObject() { try { if (isSelectStatement()) { this.setSelectStatement((SelectStatement) (this.getJpqlExpression().getQueryStatement())); } else if (isUpdateStatement()) { this.setUpdateStatement((UpdateStatement) (this.getJpqlExpression().getQueryStatement())); } else if (isDeleteStatement()) { this.setDeleteStatement((DeleteStatement) (this.getJpqlExpression().getQueryStatement())); } } catch (ClassCastException cce) { throw new JPQLParseException("Bad query format : " + cce.getMessage()); } }
/** * Compile where. */ private void compileWhere() { WhereClause whereClause = null; if (query.isSelectStatement()) { whereClause = (WhereClause) query.getSelectStatement().getWhereClause(); } else if (query.isUpdateStatement()) { whereClause = (WhereClause) query.getUpdateStatement().getWhereClause(); } if (query.isDeleteStatement()) { whereClause = (WhereClause) query.getDeleteStatement().getWhereClause(); } String content = whereClause.getConditionalExpression().toActualText(); if (whereClause != null && content.length() == 0) { throw new JPQLParseException("keyword without value[WHERE]"); } query.setFilter(content); }
throw new JPQLParseException("No column found by this name : " + property + ". Check your query.");