public class JdbcTable<P extends Persistent> extends Object implements Selectable<P>, Table<P>
| Constructor and Description |
|---|
JdbcTable(Database database,
String name,
DefinitionSource definitionSource)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
Column<?> |
addColumnAndCommit(ColumnInfo infoP)
|
void |
addListener(TableListener listener)
Add a
TableListener to this Table. |
void |
appendWhereClause(StringBuffer clause,
Persistent persistent)
Append an SQL logical expression to the given buffer to match rows
according to criteria represented by the given object.
|
CachedCount |
cachedCount() |
CachedCount |
cachedCount(Persistent criteria) |
CachedCount |
cachedCount(Persistent criteria,
boolean includeDeleted,
boolean excludeUnselectable)
A mechanism for caching a record count.
|
CachedCount |
cachedCount(String whereClause)
A mechanism for caching a record count.
|
CachedCount |
cachedCount(String whereClause,
boolean includeDeleted)
A mechanism for caching a record count.
|
CachedCount |
cachedCount(String whereClause,
boolean includeDeleted,
boolean excludeUnselectable)
A mechanism for caching a record count.
|
CachedExists |
cachedExists(String whereClause)
A mechanism for caching an existance.
|
CachedSelection<P> |
cachedSelection(String whereClause,
String orderByClause)
A mechanism for caching a selection of records.
|
Field<?> |
cachedSelectionField(String whereClause,
String orderByClause,
boolean nullable,
Integer selectedTroid,
String nameP)
Make up a Field object whose possible values are a selected
subset of the records in the table.
|
RestrictedReferencePoemType<?> |
cachedSelectionType(String whereClause,
String orderByClause,
boolean nullable)
A mechanism for caching a record count.
|
Column<Capability> |
canDeleteColumn() |
Column<Capability> |
canReadColumn() |
Column<Capability> |
canSelectColumn() |
Column<Capability> |
canWriteColumn() |
void |
clearColumnInfoCaches()
Clear caches.
|
String |
cnfWhereClause(Enumeration<P> persistents) |
String |
cnfWhereClause(Enumeration<P> persistents,
boolean includeDeleted,
boolean excludeUnselectable)
Return a Conjunctive Normal Form (CNF) where clause.
|
Enumeration<Column<?>> |
columns()
All the table's columns.
|
Column<?> |
columnWithColumnInfoID(int columnInfoID) |
int |
count() |
int |
count(String whereClause)
It is the programmer's responsibility to ensure that the where clause
is suitable for the target DBMS.
|
int |
count(String whereClause,
boolean includeDeleted)
It is the programmer's responsibility to ensure that the where clause
is suitable for the target DBMS.
|
int |
count(String whereClause,
boolean includeDeleted,
boolean excludeUnselectable)
It is the programmer's responsibility to ensure that the where clause
is suitable for the target DBMS.
|
String |
countSQL(String whereClause) |
String |
countSQL(String fromClause,
String whereClause,
boolean includeDeleted,
boolean excludeUnselectable)
Return an SQL statement to count rows put together from the arguments.
|
Persistent |
create(Initialiser initialiser)
Create a new object (record) in the table.
|
void |
create(Persistent p)
Write a new row containing the given object.
|
void |
createTableInfo()
Create the (possibly overridden) TableInfo if it has not yet been created.
|
void |
dbAddConstraints()
Constraints are not used in POEM, but you might want to use them if
exporting the db or using schema visualisation tools.
|
void |
dbModifyStructure(String sql)
Deprecated.
Use
Database.modifyStructure(String) instead |
Integer |
defaultCacheLimit() |
String |
defaultCategory() |
String |
defaultDescription()
The `factory-default' description for the table, or null if it
doesn't have one.
|
String |
defaultDisplayName()
The `factory-default' display name for the table.
|
int |
defaultDisplayOrder() |
String |
defaultOrderByClause()
If the troidColumn has yet to be set then returns an empty string.
|
boolean |
defaultRememberAllTroids() |
void |
defineColumn(Column<?> column)
Don't call this in your application code.
|
void |
delete_unsafe(String whereClause)
It is the programmer's responsibility to ensure that the where clause
is suitable for the target DBMS.
|
void |
delete(Integer troid,
PoemTransaction transaction)
The Transaction cannot be null, as this is trapped in
#deleteLock(SessionToken).
|
void |
deleteColumnAndCommit(ColumnInfo columnInfo) |
Column<Boolean> |
deletedColumn() |
Column<?> |
displayColumn()
The table's primary display column, the Troid column if not set.
|
Enumeration<Column<?>> |
displayColumns(DisplayLevel level)
Return columns at a display level in display order.
|
int |
displayColumnsCount(DisplayLevel level) |
void |
dump()
Print information about the structure of the table to stdout.
|
void |
dump(PrintStream ps)
Print information to PrintStream.
|
void |
dumpCacheAnalysis()
Print some diagnostic information about the contents and consistency of
POEM's cache for this table to stderr.
|
boolean |
equals(Object t)
Make sure that two equal table objects have the same name.
|
boolean |
exists(Persistent persistent) |
boolean |
exists(String whereClause)
It is the programmer's responsibility to ensure that the where clause
is suitable for the target DBMS.
|
int |
extrasCount()
The number of `extra' (non-DSD-defined) columns in the table.
|
P |
firstSelection(String whereClause)
Get an object satisfying the where clause.
|
Cache.Info |
getCacheInfo()
Enable reporting of the status of the cache.
|
Capability |
getCanCreate()
The capability required for creating records in the table.
|
TableCategory |
getCategory()
The category of this table.
|
Column<?> |
getColumn(String nameP)
The table's column with a given name.
|
List<Column<?>> |
getColumns()
A list of all the table's columns.
|
int |
getColumnsCount() |
Database |
getDatabase()
The database to which the table is attached.
|
String |
getDbmsTableType() |
Capability |
getDefaultCanDelete()
The capability required for deleting records in the table, unless
overridden in the record itself.
|
Capability |
getDefaultCanRead()
The capability required for reading records from the table, unless
overridden in the record itself.
|
Capability |
getDefaultCanWrite()
The capability required for updating records in the table, unless
overridden in the record itself.
|
String |
getDescription()
A brief description of the table's function.
|
Enumeration<Column<?>> |
getDetailDisplayColumns()
The table's columns for detailed display in display order.
|
int |
getDetailDisplayColumnsCount() |
String |
getDisplayName()
The human-readable name of the table.
|
TableInfo |
getInfo() |
int |
getMostRecentTroid() |
String |
getName()
The table's programmatic name.
|
int |
getNextExtrasIndex() |
Persistent |
getObject(int troid)
The object from the table with a given troid.
|
P |
getObject(Integer troid)
The object from the table with a given troid.
|
Enumeration<Column<?>> |
getRecordDisplayColumns()
The table's columns designated for display in a record, in display order.
|
int |
getRecordDisplayColumnsCount() |
Enumeration<Column<?>> |
getSearchCriterionColumns()
The table's columns designated for use as search criteria, in display
order.
|
int |
getSearchCriterionColumnsCount() |
Enumeration<Column<?>> |
getSummaryDisplayColumns()
The table's columns designated for display in a record summary, in display
order.
|
int |
getSummaryDisplayColumnsCount() |
TableInfo |
getTableInfo() |
int |
hashCode()
Ensure tables can be used as hashtable keys.
|
void |
init()
Override this to perform pre-unification initialisation.
|
void |
invalidateTransactionStuffs()
When deleting a table and used in tests.
|
void |
load(PoemTransaction transaction,
Persistent persistent) |
P |
maybeFirst(Enumeration<P> them) |
Persistent |
newPersistent() |
void |
notifyColumnInfo(ColumnInfo infoP)
Clears columnInfo caches, normally a no-op.
|
void |
notifyTouched(PoemTransaction transaction,
Persistent persistent)
Notify the table that one if its records is about to be changed in a
transaction.
|
void |
postInitialise()
Do stuff immediately after table initialisation.
|
Column<?> |
primaryCriterionColumn()
In a similar manner to the primary display column, each table can have
one primary criterion column.
|
String |
quotedName() |
void |
readLock()
Lock this record.
|
Enumeration<P> |
referencesTo(Persistent object)
All the objects in the table which refer to a given object.
|
Enumeration<Column<?>> |
referencesTo(Table<?> table)
All the columns in the table which refer to the given table.
|
void |
rememberAllTroids(boolean flag) |
Enumeration<P> |
selection()
All the objects in the table.
|
Enumeration<P> |
selection(Persistent criteria)
Return a selection of rows given an exemplar.
|
Enumeration<P> |
selection(Persistent criteria,
String orderByClause)
Return a selection of rows given arguments specifying a query.
|
Enumeration<P> |
selection(Persistent criteria,
String orderByClause,
boolean includeDeleted,
boolean excludeUnselectable)
Return a selection of rows given arguments specifying a query.
|
Enumeration<P> |
selection(String whereClause)
A SELECTion of objects from the table meeting given criteria.
|
Enumeration<P> |
selection(String whereClause,
String orderByClause,
boolean includeDeleted)
A SELECTion of objects from the table meeting given criteria,
possibly including those flagged as deleted.
|
String |
selectionSQL(String fromClause,
String whereClause,
String orderByClause,
boolean includeDeleted,
boolean excludeUnselectable)
The from clause has been added as an argument because it is
inextricably linked to the where clause, but the default is
quotedName(). |
long |
serial(PoemTransaction transaction) |
void |
setCacheLimit(Integer limit) |
void |
setDisplayColumn(Column column) |
void |
setSearchColumn(Column<?> column) |
void |
setTableInfo(TableInfo tableInfo) |
Integer |
tableInfoID()
The troid (id) of the table's entry in the tableinfo
table.
|
String |
toString()
A concise string to stand in for the table.
|
void |
trimCache(int maxSize) |
Column<Integer> |
troidColumn()
The table's troid column.
|
Integer |
troidFor(Persistent persistent) |
Enumeration<Integer> |
troidSelection(Persistent criteria,
String orderByClause,
boolean includeDeleted,
boolean excludeUnselectable,
PoemTransaction transaction) |
Enumeration<Integer> |
troidSelection(String whereClause,
String orderByClause,
boolean includeDeleted)
A SELECTion of troids of objects from the table meeting given
criteria.
|
Enumeration<Integer> |
troidSelection(String whereClause,
String orderByClause,
boolean includeDeleted,
PoemTransaction transaction)
It is the programmer's responsibility to ensure that the where clause
is suitable for the target DBMS.
|
void |
uncache()
Invalidate table cache.
|
void |
unifyWithColumnInfo()
Match columnInfo with this Table's columns.
|
void |
unifyWithDB(ResultSet colDescs,
String troidColumnName)
Unify the JDBC description of this tables columns with the
meta data held in the
TableInfo |
void |
unifyWithMetadata(ResultSet tableDescriptions)
Unify SQL REMARKS with table.description.
|
String |
whereClause(Persistent criteria)
Return an SQL WHERE clause to select rows that match the non-null
fields of the given object.
|
String |
whereClause(Persistent criteria,
boolean includeDeleted,
boolean excludeUnselectable)
Return an SQL WHERE clause to select rows using the given object
as a selection criteria and optionally deleted rows or those
included rows the user is not capable of selecting.
|
void |
writeDown(PoemTransaction transaction,
Persistent p) |
public JdbcTable(Database database, String name, DefinitionSource definitionSource)
public void init()
init in interface Table<P extends Persistent>public void postInitialise()
This base method clears the column info caches and adds a listener to the column info table to maintain the caches.
It may be overridden to perform other actions. For example to ensure required rows exist in tables that define numeric ID's for codes.
postInitialise in interface Table<P extends Persistent>notifyColumnInfo(ColumnInfo),
clearColumnInfoCaches()public final Database getDatabase()
getDatabase in interface Table<P extends Persistent>public final String getName()
getName in interface Table<P extends Persistent>Dbms.melatiName(String)public final String quotedName()
quotedName in interface Table<P extends Persistent>public final String getDisplayName()
getDisplayName in interface Table<P extends Persistent>public final String getDescription()
getDescription in interface Table<P extends Persistent>public final TableCategory getCategory()
getCategory in interface Table<P extends Persistent>public final TableInfo getInfo()
getInfo in interface Table<P extends Persistent>TableInfo for this tablepublic final Integer tableInfoID()
tableInfoID in interface Table<P extends Persistent>public final Column<?> getColumn(String nameP) throws NoSuchColumnPoemException
getColumn in interface Table<P extends Persistent>nameP - name of column to getNoSuchColumnPoemException - if there is no column with that namepublic final Enumeration<Column<?>> columns()
columns in interface Table<P extends Persistent>Columnpublic final List<Column<?>> getColumns()
TablegetColumns in interface Table<P extends Persistent>public final int getColumnsCount()
getColumnsCount in interface Table<P extends Persistent>public Column<?> columnWithColumnInfoID(int columnInfoID)
columnWithColumnInfoID in interface Table<P extends Persistent>columnInfoID - public final Column<Integer> troidColumn()
troidColumn in interface Table<P extends Persistent>getObject(java.lang.Integer)public final Column<Boolean> deletedColumn()
deletedColumn in interface Table<P extends Persistent>public final Column<?> displayColumn()
displayColumn in interface Table<P extends Persistent>ReferencePoemType._stringOfCooked(java.lang.Object, org.melati.poem.PoemLocale, int),
DisplayLevel.primarypublic final void setDisplayColumn(Column column)
setDisplayColumn in interface Table<P extends Persistent>column - the display column to setpublic final Column<?> primaryCriterionColumn()
The Primary Criterion is the main grouping field of the table, ie the most important non-unique type field.
For example the Primary Criterion for a User table might be Nationality.
primaryCriterionColumn in interface Table<P extends Persistent>Searchabilitypublic void setSearchColumn(Column<?> column)
setSearchColumn in interface Table<P extends Persistent>column - the search column to setpublic String defaultOrderByClause()
defaultOrderByClause in interface Table<P extends Persistent>public void clearColumnInfoCaches()
clearColumnInfoCaches in interface Table<P extends Persistent>public void notifyColumnInfo(ColumnInfo infoP)
notifyColumnInfo in interface Table<P extends Persistent>infoP - the possibly null ColumnInfo meta-data persistentpublic final Enumeration<Column<?>> displayColumns(DisplayLevel level)
displayColumns in interface Table<P extends Persistent>level - the DisplayLevel to selectpublic final int displayColumnsCount(DisplayLevel level)
displayColumnsCount in interface Table<P extends Persistent>level - the DisplayLevel to selectpublic final Enumeration<Column<?>> getDetailDisplayColumns()
getDetailDisplayColumns in interface Table<P extends Persistent>Column,
displayColumns(DisplayLevel),
DisplayLevel.detailpublic final int getDetailDisplayColumnsCount()
getDetailDisplayColumnsCount in interface Table<P extends Persistent>public final Enumeration<Column<?>> getRecordDisplayColumns()
getRecordDisplayColumns in interface Table<P extends Persistent>Column,
displayColumns(DisplayLevel),
DisplayLevel.recordpublic final int getRecordDisplayColumnsCount()
getRecordDisplayColumnsCount in interface Table<P extends Persistent>public final Enumeration<Column<?>> getSummaryDisplayColumns()
getSummaryDisplayColumns in interface Table<P extends Persistent>Column,
displayColumns(DisplayLevel),
DisplayLevel.summarypublic final int getSummaryDisplayColumnsCount()
getSummaryDisplayColumnsCount in interface Table<P extends Persistent>public final Enumeration<Column<?>> getSearchCriterionColumns()
getSearchCriterionColumns in interface Table<P extends Persistent>Columnpublic final int getSearchCriterionColumnsCount()
getSearchCriterionColumnsCount in interface Table<P extends Persistent>public void dbModifyStructure(String sql) throws StructuralModificationFailedPoemException
Database.modifyStructure(String) insteadTabledbModifyStructure in interface Table<P extends Persistent>sql - the SQL DDL statement to executeStructuralModificationFailedPoemExceptionpublic String getDbmsTableType()
getDbmsTableType in interface Table<P extends Persistent>Hsqldbpublic void dbAddConstraints()
dbAddConstraints in interface Table<P extends Persistent>public void invalidateTransactionStuffs()
invalidateTransactionStuffs in interface Table<P extends Persistent>public void load(PoemTransaction transaction, Persistent persistent)
load in interface Table<P extends Persistent>transaction - possibly null if working with the committed transactionpersistent - the Persistent to loadpublic void delete(Integer troid, PoemTransaction transaction)
delete in interface Table<P extends Persistent>troid - id of row to deletetransaction - a non-null transactionpublic void writeDown(PoemTransaction transaction, Persistent p)
writeDown in interface Table<P extends Persistent>transaction - our PoemTransactionp - the Persistent to writepublic void uncache()
uncache in interface Table<P extends Persistent>public void trimCache(int maxSize)
trimCache in interface Table<P extends Persistent>maxSize - new maximum sizepublic Cache.Info getCacheInfo()
getCacheInfo in interface Table<P extends Persistent>public void addListener(TableListener listener)
TableListener to this Table.addListener in interface Table<P extends Persistent>public void notifyTouched(PoemTransaction transaction, Persistent persistent)
notifyTouched in interface Table<P extends Persistent>transaction - the transaction in which the change will be madepersistent - the record to be changedpublic long serial(PoemTransaction transaction)
serial in interface Table<P extends Persistent>public void readLock()
readLock in interface Table<P extends Persistent>public P getObject(Integer troid) throws NoSuchRowPoemException
getObject in interface Selectable<P extends Persistent>getObject in interface Table<P extends Persistent>troid - Every record (object) in a POEM database must have a
troid (table row ID, or table-unique non-nullable
integer primary key), often but not necessarily called
id, so that it can be conveniently `named' for
retrieval by this method.NoSuchRowPoemException - if there is no row in the table with the given troidPersistable.getTroid()public Persistent getObject(int troid) throws NoSuchRowPoemException
getObject in interface Table<P extends Persistent>troid - the table row idNoSuchRowPoemException - if not foundgetObject(java.lang.Integer)public String selectionSQL(String fromClause, String whereClause, String orderByClause, boolean includeDeleted, boolean excludeUnselectable)
quotedName().
It is the programmer's responsibility to ensure that the where clause
is suitable for the target DBMS.selectionSQL in interface Table<P extends Persistent>fromClause - Comma separated list of table names or null for default.whereClause - SQL fragmentorderByClause - Comma separated listincludeDeleted - Flag as to whether to include soft deleted recordsexcludeUnselectable - Whether to append unselectable exclusion SQL
TODO Should work within some kind of limitpublic Enumeration<Integer> troidSelection(String whereClause, String orderByClause, boolean includeDeleted, PoemTransaction transaction)
troidSelection in interface Table<P extends Persistent>Enumeration of Troids satisfying the criteria.public Enumeration<Integer> troidSelection(Persistent criteria, String orderByClause, boolean includeDeleted, boolean excludeUnselectable, PoemTransaction transaction)
troidSelection in interface Table<P extends Persistent>criteria - Represents selection criteria possibly on joined tablestransaction - A transaction or null for
PoemThread.transaction()troidSelection(String, String, boolean, PoemTransaction)public void rememberAllTroids(boolean flag)
rememberAllTroids in interface Table<P extends Persistent>flag - whether to remember or forgetpublic void setCacheLimit(Integer limit)
setCacheLimit in interface Table<P extends Persistent>limit - the limit to setpublic Enumeration<Integer> troidSelection(String whereClause, String orderByClause, boolean includeDeleted) throws SQLPoemException
troidSelection in interface Table<P extends Persistent>whereClause - an SQL snippetorderByClause - an SQL snippetincludeDeleted - whether to include deleted records, if anySQLPoemExceptiongetObject(java.lang.Integer),
selection(java.lang.String, java.lang.String, boolean)public Enumeration<P> selection() throws SQLPoemException
selection in interface Selectable<P extends Persistent>selection in interface Table<P extends Persistent>SQLPoemExceptionSelectable.selection()public final Enumeration<P> selection(String whereClause) throws SQLPoemException
selection in interface Table<P extends Persistent>whereClause - SQL SELECTion criteria for the search:
the part that should appear after the
WHERE keywordSQLPoemExceptionColumn.selectionWhereEq(java.lang.Object)public P firstSelection(String whereClause)
firstSelection in interface Table<P extends Persistent>whereClause - SQL SELECTion criteria for the search:
the part that should appear after the
WHERE keywordpublic P maybeFirst(Enumeration<P> them)
public Enumeration<P> selection(String whereClause, String orderByClause, boolean includeDeleted) throws SQLPoemException
selection in interface Table<P extends Persistent>includeDeleted - whether to return objects flagged as deleted
(ignored if the table doesn't have a
deleted column)SQLPoemExceptionselection(java.lang.String)public Enumeration<P> selection(Persistent criteria) throws SQLPoemException
selection in interface Table<P extends Persistent>criteria - Represents selection criteria possibly on joined tablesSQLPoemExceptionselection(String, String, boolean)public Enumeration<P> selection(Persistent criteria, String orderByClause) throws SQLPoemException
selection in interface Table<P extends Persistent>criteria - Represents selection criteria possibly on joined tablesorderByClause - Comma separated listSQLPoemExceptionselection(String, String, boolean)public Enumeration<P> selection(Persistent criteria, String orderByClause, boolean includeDeleted, boolean excludeUnselectable) throws SQLPoemException
selection in interface Table<P extends Persistent>criteria - Represents selection criteria possibly on joined tablesorderByClause - Comma separated listexcludeUnselectable - Whether to append unselectable exclusion SQLSQLPoemExceptionselection(String, String, boolean)public String countSQL(String whereClause)
countSQL in interface Table<P extends Persistent>whereClause - public String countSQL(String fromClause, String whereClause, boolean includeDeleted, boolean excludeUnselectable)
countSQL in interface Table<P extends Persistent>fromClause - Comma separated list of table namespublic int count(String whereClause, boolean includeDeleted, boolean excludeUnselectable) throws SQLPoemException
count in interface Table<P extends Persistent>SQLPoemExceptionpublic int count(String whereClause, boolean includeDeleted) throws SQLPoemException
count in interface Table<P extends Persistent>SQLPoemExceptionpublic int count(String whereClause) throws SQLPoemException
count in interface Table<P extends Persistent>SQLPoemExceptionpublic int count()
throws SQLPoemException
count in interface Table<P extends Persistent>SQLPoemExceptionpublic boolean exists(String whereClause) throws SQLPoemException
exists in interface Table<P extends Persistent>whereClause - the SQL criteriaSQLPoemExceptionpublic boolean exists(Persistent persistent)
exists in interface Table<P extends Persistent>persistent - a Persistent with some fields filled inpublic void appendWhereClause(StringBuffer clause, Persistent persistent)
This default selects rows for which the non-null fields in the given object match, but subtypes may add other criteria.
The column names are now qualified with the table name so that subtypes can append elements of a join but there is no filtering by canselect columns. TODO Add mechanism for searching for Nulls (that would be query constructs as per SQL parse tree, but efferent not afferent)
appendWhereClause in interface Table<P extends Persistent>notifyColumnInfo(ColumnInfo),
clearColumnInfoCaches()public String whereClause(Persistent criteria)
This does not filter out any rows with a capability the user does not have in a canselect column, nor did it ever filter out rows deleted according to a "deleted" column. But the caller usually gets a second chance to do both.
whereClause in interface Table<P extends Persistent>public String whereClause(Persistent criteria, boolean includeDeleted, boolean excludeUnselectable)
This is currently implemented in terms of
appendWhereClause(StringBuffer, Persistent).
whereClause in interface Table<P extends Persistent>public String cnfWhereClause(Enumeration<P> persistents)
cnfWhereClause in interface Table<P extends Persistent>cnfWhereClause(Enumeration, boolean, boolean),
whereClause(Persistent)public String cnfWhereClause(Enumeration<P> persistents, boolean includeDeleted, boolean excludeUnselectable)
cnfWhereClause in interface Table<P extends Persistent>public Enumeration<P> referencesTo(Persistent object)
It is not guaranteed to be quick to execute!
referencesTo in interface Table<P extends Persistent>public Enumeration<Column<?>> referencesTo(Table<?> table)
referencesTo in interface Table<P extends Persistent>table - public int getMostRecentTroid()
getMostRecentTroid in interface Table<P extends Persistent>public Integer troidFor(Persistent persistent)
troidFor in interface Table<P extends Persistent>persistent - unused parameter, but might be needed in another troid schemapublic void create(Persistent p) throws AccessPoemException, ValidationPoemException, InitialisationPoemException
The given object will be assigned the next troid and its internal state will also be modified.
create in interface Table<P extends Persistent>InitialisationPoemException - The object failed validationAccessPoemExceptionValidationPoemExceptionpublic Persistent create(Initialiser initialiser) throws AccessPoemException, ValidationPoemException, InitialisationPoemException
create in interface Table<P extends Persistent>initialiser - A piece of code for setting the new object's
initial values. You'll probably want to define
it as an anonymous class.AccessPoemException - if initialiser provokes one during its work (which
is unlikely, since POEM's standard checks are disabled
while it runs)ValidationPoemException - if initialiser provokes one during its workInitialisationPoemException - if the object is left by initialiser in a state in
which not all of its fields have legal values, or in which
the calling thread would not be allowed write access to the
object under its AccessToken---i.e. you
can't create objects you wouldn't be allowed to write to.Initialiser.init(org.melati.poem.Persistent),
PoemThread.accessToken(),
getCanCreate()public Persistent newPersistent()
newPersistent in interface Table<P extends Persistent>public void delete_unsafe(String whereClause)
delete_unsafe in interface Table<P extends Persistent>whereClause - the criteriapublic int extrasCount()
extrasCount in interface Table<P extends Persistent>public final Capability getDefaultCanRead()
getDefaultCanRead in interface Table<P extends Persistent>public final Capability getDefaultCanWrite()
getDefaultCanWrite in interface Table<P extends Persistent>Capability required to write a
Persistent, if anypublic final Capability getDefaultCanDelete()
getDefaultCanDelete in interface Table<P extends Persistent>Capability required to delete a
Persistent, if anypublic final Capability getCanCreate()
getCanCreate in interface Table<P extends Persistent>create(org.melati.poem.Initialiser)public final Column<Capability> canReadColumn()
canReadColumn in interface Table<P extends Persistent>public final Column<Capability> canSelectColumn()
canSelectColumn in interface Table<P extends Persistent>public final Column<Capability> canWriteColumn()
canWriteColumn in interface Table<P extends Persistent>public final Column<Capability> canDeleteColumn()
canDeleteColumn in interface Table<P extends Persistent>public Column<?> addColumnAndCommit(ColumnInfo infoP) throws PoemException
addColumnAndCommit in interface Table<P extends Persistent>infoP - the meta data about the ColumnPoemExceptionpublic void deleteColumnAndCommit(ColumnInfo columnInfo) throws PoemException
deleteColumnAndCommit in interface Table<P extends Persistent>columnInfo - metadata about the column to delete, which is itself deletedPoemExceptionpublic String toString()
toString in interface Table<P extends Persistent>toString in class ObjectObject.toString()public void dumpCacheAnalysis()
dumpCacheAnalysis in interface Table<P extends Persistent>public void dump()
dump in interface Table<P extends Persistent>public void dump(PrintStream ps)
dump in interface Table<P extends Persistent>ps - PrintStream to dump topublic CachedSelection<P> cachedSelection(String whereClause, String orderByClause)
cachedSelection in interface Table<P extends Persistent>whereClause - raw SQL selection clause appropriate for this DBMSorderByClause - which field to order by or nullpublic CachedCount cachedCount(String whereClause, boolean includeDeleted)
cachedCount in interface Table<P extends Persistent>whereClause - raw SQL selection clause appropriate for this DBMSincludeDeleted - whether to include soft deleted recordspublic CachedCount cachedCount(String whereClause, boolean includeDeleted, boolean excludeUnselectable)
cachedCount in interface Table<P extends Persistent>whereClause - raw SQL selection clause appropriate for this DBMSincludeDeleted - whether to include soft deleted recordsexcludeUnselectable - whether to exclude columns which cannot be selectedpublic CachedCount cachedCount(Persistent criteria, boolean includeDeleted, boolean excludeUnselectable)
cachedCount in interface Table<P extends Persistent>criteria - a Persistent with selection fields filledincludeDeleted - whether to include soft deleted recordsexcludeUnselectable - whether to exclude columns which cannot be selectedpublic CachedCount cachedCount(Persistent criteria)
cachedCount in interface Table<P extends Persistent>criteria - a Persistent to extract where clause frompublic CachedCount cachedCount(String whereClause)
cachedCount in interface Table<P extends Persistent>whereClause - raw SQL selection clause appropriate for this DBMSpublic CachedCount cachedCount()
cachedCount in interface Table<P extends Persistent>public CachedExists cachedExists(String whereClause)
cachedExists in interface Table<P extends Persistent>whereClause - raw SQL selection clause appropriate for this DBMSpublic RestrictedReferencePoemType<?> cachedSelectionType(String whereClause, String orderByClause, boolean nullable)
cachedSelectionType in interface Table<P extends Persistent>whereClause - raw SQL selection clause appropriate for this DBMSorderByClause - raw SQL order clause appropriate for this DBMSnullable - whether the ReferencePoemType is nullableRestrictedReferencePoemTypepublic Field<?> cachedSelectionField(String whereClause, String orderByClause, boolean nullable, Integer selectedTroid, String nameP)
context.put("greens",
melati.getDatabase().getCustomerTable().cachedSelectionField(
"colour = 'green'", null, true, null, "greens"));
and this in your template
The list of member records is implicitly cached---permanently, and however big it turns out to be. So don't go mad with this. It is recomputed on demand if the contents of the table are changed. The whereClause and orderByClause you pass in are checked to see if you have asked for the same list before, so however many times you call this method, you should only trigger actual SELECTs when the table contents have changed. The list is also transaction-safe, in that it will always reflect the state of affairs within your transaction even if you haven't done a commit. It is the programmer's responsibility to ensure that the WHERE clause is suitable for the target DBMS.Select a customer: $ml.input($greens)
cachedSelectionField in interface Table<P extends Persistent>whereClause - an SQL expression (the bit after the
SELECT ... WHERE) for picking
out the records you wantorderByClause - a comma-separated list of column names which
determine the order in which the records are
presented; if this is null, the
displayorderpriority attributes of the
table's columns determine the ordernullable - whether to allow a blank NULL option
as the first possibilityselectedTroid - the troid of the record to which the
SELECT field should initially be setnameP - the HTML name attribute of the field,
i.e.
<SELECT NAME=name>public final void defineColumn(Column<?> column) throws DuplicateColumnNamePoemException, DuplicateTroidColumnPoemException, DuplicateDeletedColumnPoemException
defineColumn in interface Table<P extends Persistent>DuplicateColumnNamePoemExceptionDuplicateTroidColumnPoemExceptionDuplicateDeletedColumnPoemExceptionpublic int getNextExtrasIndex()
getNextExtrasIndex in interface Table<P extends Persistent>public TableInfo getTableInfo()
getTableInfo in interface Table<P extends Persistent>TableInfo for this table.public void setTableInfo(TableInfo tableInfo)
setTableInfo in interface Table<P extends Persistent>tableInfo - the TableInfo to setpublic String defaultDisplayName()
defaultDisplayName in interface Table<P extends Persistent>public int defaultDisplayOrder()
defaultDisplayOrder in interface Table<P extends Persistent>public String defaultDescription()
defaultDescription in interface Table<P extends Persistent>public Integer defaultCacheLimit()
defaultCacheLimit in interface Table<P extends Persistent>public boolean defaultRememberAllTroids()
defaultRememberAllTroids in interface Table<P extends Persistent>public String defaultCategory()
defaultCategory in interface Table<P extends Persistent>public void createTableInfo()
throws PoemException
createTableInfo in interface Table<P extends Persistent>PoemExceptionpublic void unifyWithColumnInfo()
throws PoemException
unifyWithColumnInfo in interface Table<P extends Persistent>PoemExceptionpublic void unifyWithMetadata(ResultSet tableDescriptions) throws SQLException
TableunifyWithMetadata in interface Table<P extends Persistent>tableDescriptions - a JDBC ResultSet with cursor at current rowSQLExceptionpublic void unifyWithDB(ResultSet colDescs, String troidColumnName) throws PoemException
TableInfounifyWithDB in interface Table<P extends Persistent>colDescs - a JDBC ResultSet describing the columns with cursor at current rowtroidColumnName - name of primary key columnPoemExceptionpublic final int hashCode()
hashCode in class ObjectObject.hashCode()public boolean equals(Object t)
equals in class ObjectObject.equals(java.lang.Object)Copyright © 2000–2021 PanEris. All rights reserved.