@Test public void testNonStandardFunctionCall() { final String query = "select o from Entity o where my_func(o.basic) = 1"; ConsumerContextImpl consumerContext = new ConsumerContextImpl(buildMetamodel()); // first test HQL superset is allowed... SemanticQueryInterpreter.interpret(query, consumerContext); // now enable strict compliance and try again, should lead to error consumerContext.enableStrictJpaCompliance(); try { SemanticQueryInterpreter.interpret(query, consumerContext); fail("expected violation"); } catch (StrictJpaComplianceViolation v) { assertEquals(StrictJpaComplianceViolation.Type.FUNCTION_CALL, v.getType()); } }
@Test public void testUnmappedPolymorphicReference() { final String query = "select o from PolymorphicEntity o"; ConsumerContextImpl consumerContext = new ConsumerContextImpl(buildMetamodel()); // first test HQL superset is allowed... SemanticQueryInterpreter.interpret(query, consumerContext); // now enable strict compliance and try again, should lead to error consumerContext.enableStrictJpaCompliance(); try { SemanticQueryInterpreter.interpret(query, consumerContext); fail("expected violation"); } catch (StrictJpaComplianceViolation v) { assertEquals(StrictJpaComplianceViolation.Type.UNMAPPED_POLYMORPHISM, v.getType()); } }
@Test public void testAliasedFetchJoin() { final String query = "select o from Entity o join fetch o.entity e"; ConsumerContextImpl consumerContext = new ConsumerContextImpl(buildMetamodel()); // first test HQL superset is allowed... SemanticQueryInterpreter.interpret(query, consumerContext); // now enable strict compliance and try again, should lead to error consumerContext.enableStrictJpaCompliance(); try { SemanticQueryInterpreter.interpret(query, consumerContext); fail("expected violation"); } catch (StrictJpaComplianceViolation v) { assertEquals(StrictJpaComplianceViolation.Type.ALIASED_FETCH_JOIN, v.getType()); } }
@Test public void testImplicitSelectClause() { final String query = "from Entity"; ConsumerContextImpl consumerContext = new ConsumerContextImpl(buildMetamodel()); // first test HQL superset is allowed... SemanticQueryInterpreter.interpret(query, consumerContext); // now enable strict compliance and try again, should lead to error consumerContext.enableStrictJpaCompliance(); try { SemanticQueryInterpreter.interpret(query, consumerContext); fail("expected violation"); } catch (StrictJpaComplianceViolation v) { assertEquals(StrictJpaComplianceViolation.Type.IMPLICIT_SELECT, v.getType()); } }