### Question:
JPQLSerializer extends SerializerBase<JPQLSerializer> { public void serializeForDelete(QueryMetadata md) { append(DELETE); handleJoinTarget(md.getJoins().get(0)); if (md.getWhere() != null) { append(WHERE).handle(md.getWhere()); } } JPQLSerializer(JPQLTemplates templates);  JPQLSerializer(JPQLTemplates templates, EntityManager em); void serialize(QueryMetadata metadata, boolean forCountRow, @Nullable String projection); void serializeForDelete(QueryMetadata md); void serializeForInsert(QueryMetadata md, List<Path<?>> columns, List<Object> values, SubQueryExpression<?> query, Map<Path<?>, Expression<?>> inserts); void serializeForUpdate(QueryMetadata md, Map<Path<?>, Expression<?>> updates); @Override void visitConstant(Object constant); void visitLiteral(Object constant); @Override Void visit(ParamExpression<?> param, Void context); @Override Void visit(SubQueryExpression<?> query, Void context); @Override Void visit(Path<?> expr, Void context);  }### Answer:
@Test public void delete_clause_uses_dELETE_fROM() { QEmployee employee = QEmployee.employee; JPQLSerializer serializer = new JPQLSerializer(HQLTemplates.DEFAULT); QueryMetadata md = new DefaultQueryMetadata(); md.addJoin(JoinType.DEFAULT, employee); md.addWhere(employee.lastName.isNull()); serializer.serializeForDelete(md); assertEquals("delete from Employee employee\nwhere employee.lastName is null", serializer.toString()); }
@Test public void delete_with_subQuery() { QCat parent = QCat.cat; QCat child = new QCat("kitten"); JPQLSerializer serializer = new JPQLSerializer(HQLTemplates.DEFAULT); QueryMetadata md = new DefaultQueryMetadata(); md.addJoin(JoinType.DEFAULT, child); md.addWhere( child.id.eq(1) .and(selectOne() .from(parent) .where(parent.id.eq(2), child.in(parent.kittens)).exists())); serializer.serializeForDelete(md); assertEquals("delete from Cat kitten\n" + "where kitten.id = ?1 and exists (select 1\n" + "from Cat cat\nwhere cat.id = ?2 and kitten member of cat.kittens)", serializer.toString()); }