alias<Row extends Object, RS extends ResultSet<Row, RS>> method

RS alias<Row extends Object, RS extends ResultSet<Row, RS>>(
  1. ResultSet<Row, RS> table,
  2. String alias
)

Creates a copy of the table with an alias so that it can be used in the same query more than once.

Example which uses the same table (here: points) more than once to differentiate between the start and end point of a route:

var source = alias(points, 'source');
var destination = alias(points, 'dest');

select(routes).join([
  innerJoin(source, routes.startPoint.equalsExp(source.id)),
  innerJoin(destination, routes.startPoint.equalsExp(destination.id)),
]);

Implementation

RS alias<Row extends Object, RS extends ResultSet<Row, RS>>(
  ResultSet<Row, RS> table,
  String alias,
) {
  return table.withAlias(alias).asSelfType();
}