@Test public void testQueryHandlerException() { QueryHandlerException exception = new QueryHandlerException(); Assert.assertNotNull(exception); exception = new QueryHandlerException("Error with string"); Assert.assertNotNull(exception); exception = new QueryHandlerException("Error with string and runtime error", new RuntimeException()); Assert.assertNotNull(exception); exception = new QueryHandlerException(new RuntimeException()); Assert.assertNotNull(exception); }
@Test public void testValidateQuery() { String query = " Select p from MappedPerson p"; try { em.createQuery(query); Assert.fail("Should have gone to catch block!"); } catch (QueryHandlerException qhex) { Assert.assertEquals("No entity found by the name: MappedPerson", qhex.getMessage()); } }
throw new QueryHandlerException("Shape " + shape.getClass() + " is not supported" + " in JPA queries for operator " + operator + " in Kundera currently"); throw new QueryHandlerException("Shape " + shape.getClass() + " is not supported" + " in JPA queries for operator " + operator + " in Kundera currently");
private void findByNameAndAgeWithOrClause() { EntityManager em; String query; Query q; List<StudentMongoBooleanWrapper> students; int count; em = emf.createEntityManager(); query = "Select s From StudentMongoBooleanWrapper s where s.name = Kuldeep or s.age > " + getMinValue(short.class); try { q = em.createQuery(query); students = q.getResultList(); Assert.assertNotNull(students); Assert.assertEquals(2, students.size()); count = 0; for (StudentMongoBooleanWrapper student : students) { Assert.assertEquals("Kuldeep", student.getName()); count++; } Assert.assertEquals(2, count); em.close(); } catch (QueryHandlerException qhe) { Assert.assertEquals("unsupported clause OR for Mongo", qhe.getMessage()); } }
public static Neo4JNativeQuery getNativeQueryImplementation(Neo4JQueryType queryType) { if (queryType.equals(Neo4JQueryType.LUCENE)) { return new Neo4JLuceneQuery(); } /* * else if (queryType.equals(Neo4JQueryType.CYPHER)) { return new * Neo4JCypherQuery(); } */ /* * else if (queryType.equals(Neo4JQueryType.GREMLIN)) { * * } */ else { throw new QueryHandlerException("Invalid Query Type:" + queryType + ".Can't determine and implementation for running this type for native query for Neo4J"); } } }
private void findByNameAndAgeWithOrClause() { EntityManager em; String query; Query q; List<StudentMongoBooleanPrimitive> students; int count; em = emf.createEntityManager(); query = "Select s From StudentMongoBooleanPrimitive s where s.name = Kuldeep or s.age > " + getMinValue(short.class); try { q = em.createQuery(query); students = q.getResultList(); Assert.assertNotNull(students); Assert.assertEquals(2, students.size()); count = 0; for (StudentMongoBooleanPrimitive student : students) { Assert.assertEquals("Kuldeep", student.getName()); count++; } Assert.assertEquals(2, count); em.close(); } catch (QueryHandlerException qhe) { Assert.assertEquals("unsupported clause OR for Mongo", qhe.getMessage()); } }
throw new QueryHandlerException(e); throw new QueryHandlerException(e);
@Test public void testCreateQueryWithNull() { PersistenceDelegator pd = ((EntityManagerImpl) em).getPersistenceDelegator(); try { pd.createQuery(null); Assert.fail("Should have gone to catch block!"); } catch (QueryHandlerException qhex) { Assert.assertEquals("Query String should not be null ", qhex.getMessage()); } }
private void validateClause(RedisQueryInterpreter interpreter, String condition, String columnName) { if (interpreter.getClause() != null) { if (interpreter.getFieldName() != null && !interpreter.getFieldName().equals(columnName)) { throw new QueryHandlerException( "Nested AND/OR clause is not supported for different set of fields for condition:" + condition); } } interpreter.setFieldName(columnName); }
Assert.assertEquals("unsupported clause OR for cassandra", qhe.getMessage());
/** * Sets parameter value into filterClause, depending upon {@link Type}. * * @param name * parameter name. * @param value * parameter value. */ private void setParameterValue(String name, Object value) { if (typedParameter != null) { List<FilterClause> clauses = typedParameter.getParameters() != null ? typedParameter.getParameters().get(name) : null; if (clauses != null) { for (FilterClause clause : clauses) { clause.setValue(value); } } else { if (typedParameter.getUpdateParameters() != null) { UpdateClause updateClause = typedParameter.getUpdateParameters().get(name); updateClause.setValue(value); } else { logger.error("Error while setting parameter."); throw new QueryHandlerException("named parameter : " + name + " not found!"); } } } else { throw new QueryHandlerException("No named parameter present for query"); } }
Assert.assertEquals("unsupported clause OR for cassandra", qhe.getMessage());
String token = tokenizer.nextToken(); if (!StringUtils.containsAny(fromArray[1] + ".", token)) { throw new QueryHandlerException("bad query format with invalid alias:" + token); "No entity {} found, please verify it is properly annotated with @Entity and not a mapped Super class", entityName); throw new QueryHandlerException("No entity found by the name: " + entityName); throw new QueryHandlerException(entityClass + " is not indexed. Not possible to run a query on it." + " Check whether it was properly annotated for indexing.");
Assert.assertEquals("unsupported clause OR for cassandra", qhe.getMessage());
throw new QueryHandlerException("Incomplete partition key fields in query");
Assert.assertEquals("unsupported clause OR for cassandra", qhe.getMessage());
@Override protected int onExecuteUpdate() { Map<String, Object> persistDetails = new HashMap<String, Object>(); DataFrame dataFrame; try { String query = getJPAQuery();// .toLowerCase(); persistDetails = parseInsertIntoQuery(query); dataFrame = getDataFrameToPersist(query, (String) persistDetails.get("fetchQuery")); String clientName = (String) persistDetails.get("client"); SparkDataClient dataClient = SparkDataClientFactory.getDataClient(clientName); dataClient.saveDataFrame(dataFrame, getEntityMetadata().getEntityClazz(), persistDetails); } catch (Exception e) { logger.error("Error during executing query, Caused by:", e); throw new QueryHandlerException(e); } return getDataFrameSize(dataFrame); }
Assert.assertNotNull(qhe.getMessage());
throw new QueryHandlerException("Query String should not be null "); throw new QueryHandlerException("unexpected char: ';' in query [ " + jpaQuery + " ]"); throw new QueryHandlerException(e); throw new QueryHandlerException(e);
Assert.assertNotNull(qhe.getMessage());