public abstract class Table<R extends Table<R>> extends Object
public class Person extends Table<Person> {
// definition order is crucial and must match the order in which fields are selected
public final Col<String> name = stringCol();
public final Col<Date> age = date();
public Person(Object[] row) {
super(row);
// necessary call to init();
init();
}
}
// usage
// (SELECT name, age FROM Person;)
// ATTENTION! SELECT age, name FROM Person; does NOT work!
final Object[] select = sqlSelect();
final MyTable t = new MyTable(select);
final String name = t.get(t.name);
final Date age = t.get(t.age);
| Modifier and Type | Class and Description |
|---|---|
protected class |
Table.Col<A> |
| Modifier and Type | Method and Description |
|---|---|
Table.Col<Boolean> |
booleanCol()
Define a column of type boolean.
|
Table.Col<Date> |
dateCol()
Define a column of type Date.
|
Table.Col<org.joda.time.DateTime> |
dateTimeCol()
Define a column of type DateTime.
|
<A> A |
get(Table.Col<A> col)
Access a column.
|
protected void |
init()
Call this in the subclass's constructor!
|
Table.Col<Long> |
longCol()
Define a column of type long.
|
Table.Col<String> |
stringCol()
Define a column of type String.
|
public Table(Object[] row)
public Table.Col<org.joda.time.DateTime> dateTimeCol()
Date by JPA.protected void init()
A call to init() can't happen in the abstract class's constructor since field definitions haven't been initialized yet.
public <A> A get(Table.Col<A> col)
Copyright © 2009–2020 Opencast Project. All rights reserved.