### Question:
NativeSQLSerializer extends SQLSerializer { @Override public void serialize(QueryMetadata metadata, boolean forCountRow) { boolean modified = false; Set<String> used = new HashSet<String>(); Expression<?> projection = metadata.getProjection(); if (projection instanceof Path) { Path<?> path = (Path<?>) projection; if (!used.add(path.getMetadata().getName())) { String alias = "col_1"; aliases.put(projection, alias); projection = ExpressionUtils.as(projection, alias); modified = true; } else if (path.getAnnotatedElement().isAnnotationPresent(Column.class)) { Column column = path.getAnnotatedElement().getAnnotation(Column.class); if (!column.name().isEmpty()) { aliases.put(path, column.name()); } else { aliases.put(path, ColumnMetadata.getName(path)); } } else { aliases.put(path, ColumnMetadata.getName(path)); } } else if (projection instanceof FactoryExpression) { FactoryExpression<?> factoryExpr = (FactoryExpression<?>) projection; List<Expression<?>> fargs = Lists.newArrayList(factoryExpr.getArgs()); for (int j = 0; j < fargs.size(); j++) { if (fargs.get(j) instanceof Path) { Path<?> path = (Path<?>) fargs.get(j); String columnName; if (path.getAnnotatedElement().isAnnotationPresent(Column.class)) { Column column = path.getAnnotatedElement().getAnnotation(Column.class); if (!column.name().isEmpty()) { columnName = column.name(); } else { columnName = ColumnMetadata.getName(path); } } else { columnName = ColumnMetadata.getName(path); } if (!used.add(columnName)) { String alias = "col_" + (j + 1); aliases.put(path, alias); fargs.set(j, ExpressionUtils.as(fargs.get(j), alias)); } else { aliases.put(path, columnName); } } else if (isAlias(fargs.get(j))) { Operation<?> operation = (Operation<?>) fargs.get(j); aliases.put(operation, operation.getArg(1).toString()); } else if (!isAllExpression(fargs.get(j))) { String alias = "col_" + (j + 1); aliases.put(fargs.get(j), alias); fargs.set(j, ExpressionUtils.as(fargs.get(j), alias)); } } projection = Projections.tuple(ImmutableList.copyOf(fargs)); modified = true; } else if (isAlias(projection)) { Operation<?> operation = (Operation<?>) projection; aliases.put(operation, operation.getArg(1).toString()); } else { if (!isAllExpression(projection)) { String alias = "col_1"; aliases.put(projection, alias); projection = ExpressionUtils.as(projection, alias); modified = true; } } if (modified) { metadata = metadata.clone(); metadata.setProjection(projection); } super.serialize(metadata, forCountRow); } NativeSQLSerializer(Configuration configuration);  NativeSQLSerializer(Configuration configuration, boolean wrapEntityProjections); ListMultimap<Expression<?>, String> getAliases(); @Override void serialize(QueryMetadata metadata, boolean forCountRow); @Override void visitConstant(Object constant);  }### Answer:
@Test public void in() { Configuration conf = new Configuration(new MySQLTemplates()); NativeSQLSerializer serializer = new NativeSQLSerializer(conf, true); DefaultQueryMetadata md = new DefaultQueryMetadata(); SAnimal cat = SAnimal.animal_; md.addJoin(JoinType.DEFAULT, cat); md.addWhere(cat.name.in("X", "Y")); md.setProjection(cat.id); serializer.serialize(md, false); assertEquals("select animal_.id\n" + "from animal_ animal_\n" + "where animal_.name in (?1, ?2)", serializer.toString()); }