You need to keep a reference to your column that you want to alias.
That column expression gets past to the select method and the orderBy
method. Remember to think out-of-order from linear SQL. You can create
a column alias and then select it. You can join on this table or that
table depending on your conditions.

I haven't tested to see if it works with a union. What happens when you do this?

DBColumnExpr title = db.serie.title.as("title");

cmd.select(db.album.id,db.album.title,db.album.index,db.album.serieId,
title); //<-- last argument is the reference declare on line 1.

cmd.orderBy(title); //<-- same reference.



Exxos wrote:

> If you allow >>> DBColumnExpr.as(<String>)
> then please add the following signature >> DBCommandExpr.orderBy(<String>);
> otherwise there is a gap.

> Please consider the following use case:

> DBCommand cmd = db.createCommand();
> cmd.select(db.album.id,db.album.title,db.album.index,db.album.serieId, 
> db.serie.title.as("title"));
> cmd.where(db.album.serieId.is(db.serie.id));

> DBCommand cmdUnion = db.createCommand();
> cmdUnion.select(db.album.id,db.album.title,db.album.index,db.album.serieId,db.album.title.as("title"));
> cmdUnion.where(db.album.serieId.is(null));

> DBCommandExpr cmdExpr = cmd.union(cmdUnion);
> >>>>> cmdExpr.orderBy("title"); <<<<<<<

> Did I miss something?

Reply via email to