serializer.serializeUnion(union, queryMixin.getMetadata(), unionAll);
} else {
QueryMixin mixin2 = new QueryMixin(queryMixin.getMetadata().clone());
Set<Path<?>> paths = getRootPaths(expandProjection(mixin2.getMetadata().getProjection()));
if (paths.isEmpty()) {
mixin2.from(ExpressionUtils.as((Expression) union, defaultQueryAlias));
} else if (paths.size() == 1) {
mixin2.from(ExpressionUtils.as((Expression) union, paths.iterator().next()));
} else {
throw new IllegalStateException("Unable to create serialize union");
}