|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.ujorm.orm.template.AliasTable<UJO>
public class AliasTable<UJO extends OrmUjo>
The experimental class for building any SQL statement using Ujorm Keys.
Example:
import static org.ujorm.orm.template.AliasTable.Build.*; public void example() { OrmHandler handler = createHandler(); AliasTable<Order> order = handler.tableOf(Order.class, "order"); AliasTable<Item> item = handler.tableOf(Item.class, "item"); 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); }
| Nested Class Summary | |
|---|---|
static class |
AliasTable.Build
Static building methods. |
| Constructor Summary | |
|---|---|
|
AliasTable(Class<UJO> table,
String alias,
OrmHandler handler)
|
protected |
AliasTable(TableWrapper table,
OrmHandler handler)
|
| Method Summary | ||
|---|---|---|
String |
allColumns()
Call the column() method for all Keys of Ujorm |
|
String |
allColumns(boolean includeKeyAlias)
Call the column() method for all Keys of Ujorm |
|
|
column(Key<UJO,T> key)
Print one columnAs including alias |
|
|
columnAs(Key<UJO,T> key)
Returns one column including an default special alias name after the 'AS' phrase. |
|
|
columnAs(Key<UJO,T> key,
CharSequence columnAlias)
Returns one column including the required alias name after the 'AS' phrase. |
|
|
columnAs(String expression,
Key<UJO,T> key)
Print one columnAs including alias |
|
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
|
of(Class<UJO> table,
OrmHandler handler)
Create new Alias with default name |
|
static
|
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 with Alias |
|
String |
toString()
Return the same result as table |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public AliasTable(Class<UJO> table,
String alias,
OrmHandler handler)
protected AliasTable(TableWrapper table,
OrmHandler handler)
| Method Detail |
|---|
protected SqlDialect getDialect()
public TableWrapper getTableModel()
public String table()
throws IllegalStateException
IllegalStateException
public <T> String columnAs(String expression,
Key<UJO,T> key)
throws IllegalStateException
IllegalStateException
public <T> String column(Key<UJO,T> key)
throws IllegalStateException
IllegalStateException
public <T> String columnAs(Key<UJO,T> key)
throws IllegalStateException
IllegalStateException
public <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.
IllegalStateException
public String allColumns()
throws IllegalStateException
IllegalStateException
public String allColumns(boolean includeKeyAlias)
throws IllegalStateException
IllegalStateExceptionpublic String toString()
table
toString in class Object
protected 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.
IllegalStateException
protected MetaColumn findColumnModel(Key<UJO,?> key)
throws IllegalArgumentException
IllegalArgumentException
public 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)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||