alias<T extends Table, D> method Null safety

T alias<T extends Table, D>(
  1. TableInfo<T, D> 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

T alias<T extends Table, D>(TableInfo<T, D> table, String alias) {
  return table.createAlias(alias).asDslTable;
}