public class AliasTable<UJO extends OrmUjo> extends Object
import static org.ujorm.orm.template.AliasTable.Build.*;
public void example() {
OrmHandler handler = createHandler();
AliasTable<Order> order = AliasTable.of(Order.class, "order", handler);
AliasTable<Item> item = AliasTable.of(Item.class, "item", handler);
String sql
= SELECT(order.column(Order.CREATED), item.column(Item.NOTE))
+ FROM (order, item)
+ WHERE(order.column(Order.ID), " = ", item.column(Item.ORDER));
String sqlExpected = "SELECT order.CREATED, item.NOTE "
+ "FROM db1.ord_order order, db1.ord_item item "
+ "WHERE order.ID = item.fk_order";
assertEquals(sqlExpected, sql);
}| Modifier and Type | Class and Description |
|---|---|
static class |
AliasTable.Build
Static building methods.
|
| Modifier | Constructor and Description |
|---|---|
|
AliasTable(Class<UJO> table,
String alias,
OrmHandler handler) |
protected |
AliasTable(TableWrapper table,
OrmHandler handler) |
| Modifier and Type | Method and Description |
|---|---|
String |
allColumns()
Call the column() method for all Keys of Ujorm
|
String |
allColumns(boolean includeKeyAlias)
Call the column() method for all Keys of Ujorm
|
<T> String |
column(Key<UJO,T> key)
Print one column including alias
|
<T> String |
columnAs(Key<UJO,T> key)
Returns one column including an default special alias name after the 'AS' phrase.
|
<T> String |
columnAs(Key<UJO,T> key,
CharSequence columnAlias)
Returns one column including the required alias name after the 'AS' phrase.
|
protected MetaColumn |
findColumnModel(Key<UJO,?> key)
Find Column Model or throw an IllegalArgumentException.
|
protected SqlDialect |
getDialect()
Returns SQL Dialect
|
TableWrapper |
getTableModel()
Get table Alias
|
static <UJO extends OrmUjo> |
of(Class<UJO> table,
OrmHandler handler)
Create new Alias with default name
|
static <UJO extends OrmUjo> |
of(Class<UJO> table,
String alias,
OrmHandler handler)
Create new Alias with required name
|
protected StringBuilder |
printColumn(MetaColumn column,
CharSequence columnAlias,
StringBuilder out)
Returns one column including an default special alias after the 'AS' phrase.
|
String |
table()
Returns Table witn Alias
|
String |
toString()
Return the same result as
table |
public AliasTable(Class<UJO> table, String alias, OrmHandler handler)
protected AliasTable(TableWrapper table, OrmHandler handler)
protected SqlDialect getDialect()
public TableWrapper getTableModel()
public String table() throws IllegalStateException
IllegalStateExceptionpublic <T> String column(Key<UJO,T> key) throws IllegalStateException
IllegalStateExceptionpublic <T> String columnAs(Key<UJO,T> key) throws IllegalStateException
IllegalStateExceptionpublic <T> String columnAs(Key<UJO,T> key, CharSequence columnAlias) throws IllegalStateException
key - Related keycolumnAlias - an alias String or a Key instance for the key Name, the null value use an Key name.IllegalStateExceptionpublic String allColumns() throws IllegalStateException
IllegalStateExceptionpublic String allColumns(boolean includeKeyAlias) throws IllegalStateException
IllegalStateExceptionprotected StringBuilder printColumn(MetaColumn column, CharSequence columnAlias, StringBuilder out) throws IllegalStateException
key - Related keycolumnAlias - an alias name or a Key instance, the null value use an Key name.IllegalStateExceptionprotected MetaColumn findColumnModel(Key<UJO,?> key) throws IllegalArgumentException
IllegalArgumentExceptionpublic static <UJO extends OrmUjo> AliasTable<UJO> of(Class<UJO> table, String alias, OrmHandler handler)
public static <UJO extends OrmUjo> AliasTable<UJO> of(Class<UJO> table, OrmHandler handler)
Copyright 2013, Pavel Ponec