Not really sure about what you are doing here. Shouldn't the root alias be decided by the expression visitor? Also: shouldn't the expression visitor build a new QueryBuilder (or query) instead of using one passed as constructor param? While this approach gives more flexibility, it is quite error prone.

tl;dr: you're doing half of the stuff here, and half in the expression visitor