public class DatabaseStorageManager extends Object implements StorageManager<DatabaseStorageManagerFactory>
| Modifier and Type | Class and Description |
|---|---|
protected static class |
DatabaseStorageManager.InputStreamBlob |
| Modifier and Type | Field and Description |
|---|---|
protected Connection |
activeConnection
The currently active Connection.
|
protected Map<MMObjectNode,String> |
changes
Pool of changed nodes in a transaction
|
protected DatabaseStorageManagerFactory |
factory
The factory that created this manager
|
protected boolean |
inTransaction
true if a transaction has been started. |
static int |
OBJ2TYPE_MAX_SIZE
Max size of the object type cache
|
protected static List<Integer> |
sequenceKeys |
protected int |
transactionIsolation
The transaction issolation level to use when starting a transaction.
|
protected static Cache<Integer,Integer> |
typeCache
The cache that contains the last X types of all requested objects
|
| Constructor and Description |
|---|
DatabaseStorageManager()
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
addToTableNameCache(String name) |
static StringBuilder |
appendDirectory(StringBuilder pathBuffer,
int number,
String separator)
Appends subdirectories to the beginning of the given StringBuilder.
|
protected void |
appendField(StringBuilder fieldNames,
StringBuilder fieldValues,
CoreField field) |
void |
beginTransaction()
Starts a transaction on this StorageManager instance.
|
void |
change(CoreField field)
Changes a field to the storage of this builder.
|
void |
change(MMObjectBuilder builder)
Changes the storage of a builder to match its new configuration.
|
void |
change(MMObjectNode node)
Commit this node to the specified builder.
|
protected void |
change(MMObjectNode node,
MMObjectBuilder builder)
Change this node in the specified builder.
|
protected void |
change(MMObjectNode node,
MMObjectBuilder builder,
String tableName,
Collection<CoreField> changeFields)
Commits changes in node to table.
|
protected File |
checkFile(File binaryFile,
MMObjectNode node,
CoreField field)
Checks whether file is readable and existing.
|
void |
commit()
Closes any transaction that was started and commits all changes.
|
protected void |
commitChange(MMObjectNode node,
String change)
Commits the change to a node.
|
protected boolean |
compareIndex(List<String> indexFields,
Index index) |
int |
convertLegacyBinaryFiles()
Convert legacy file
|
void |
create()
Create the basic elements for this storage
|
void |
create(CoreField field)
Creates a field and adds it to the storage of this builder.
|
protected void |
create(Index index)
Create an index or a unique constraint.
|
void |
create(MMObjectBuilder builder)
Create a storage element to store the specified builder's objects.
|
int |
create(MMObjectNode node)
This method creates a new object in the storage, and registers the change.
|
protected void |
create(MMObjectNode node,
List<CoreField> createFields,
String tablename) |
protected void |
create(MMObjectNode node,
MMObjectBuilder builder)
This method inserts a new object in a specific builder, and registers the change.
|
protected void |
createIndex(Index index,
String tablename)
Create an index or a unique constraint.
|
protected void |
createIndices(CoreField field)
(Re)create all constraints and indices that contain a specific field.
|
int |
createKey()
Gives an unique number for a new node, to be inserted in the storage.
|
protected void |
createSequence()
Creates a means for the database to pre-create keys with increasing numbers.
|
protected void |
createTable(MMObjectBuilder builder,
List<CoreField> tableFields,
String tableName) |
void |
delete(CoreField field)
Deletes a field from the storage of this builder.
|
protected void |
delete(Index index)
Drop a constraint or index.
|
void |
delete(MMObjectBuilder builder)
Drops the storage of this builder.
|
void |
delete(MMObjectNode node)
Delete a node
|
protected void |
delete(MMObjectNode node,
MMObjectBuilder builder)
Delete a node from a specific builder
This method makes it easier to implement relational databases, where you may need to remove the node
in more than one builder.
|
protected void |
delete(MMObjectNode node,
MMObjectBuilder builder,
List<CoreField> blobFileField,
String tablename) |
protected void |
deleteIndices(CoreField field)
Drop all constraints and indices that contain a specific field.
|
void |
executeQuery(String sql,
ResultSetReader reader) |
protected int |
executeUpdate(String query,
MMObjectNode node,
List<CoreField> fields)
Executes an update query for given node and fields.
|
protected int |
executeUpdateCheckConnection(String query,
MMObjectNode node,
List<CoreField> fields)
Executes an update query for given node and fields.
|
boolean |
exists()
Determine if the basic storage elements exist
Basic storage elements include the 'object' storage (where all objects and their types are registered).
|
protected boolean |
exists(Index index)
Determines if an index exists.
|
protected boolean |
exists(Index index,
String tablename)
Determines if an index exists.
|
boolean |
exists(MMObjectBuilder builder)
Determine if a storage element exists for storing the given builder's objects
|
protected boolean |
exists(String tableName)
Queries the database metadata to test whether a given table exists.
|
protected void |
fillNode(MMObjectNode node,
ResultSet result,
MMObjectBuilder builder)
Fills a single Node from the resultset of a query.
|
protected Connection |
getActiveConnection()
Obtains an active connection, opening a new one if needed.
|
protected File |
getBinaryFile(MMObjectNode node,
String fieldName)
Defines how binary (blob) data files must look like.
|
byte[] |
getBinaryValue(MMObjectNode node,
CoreField field)
Retrieve a large binary object (byte array) for a specified object field.
|
protected Blob |
getBlobFromDatabase(MMObjectNode node,
CoreField field,
boolean mayShorten)
Read a binary (blob) from a field in the database
|
Blob |
getBlobValue(MMObjectNode node,
CoreField field) |
Blob |
getBlobValue(MMObjectNode node,
CoreField field,
boolean mayShorten) |
protected Blob |
getBlobValue(ResultSet result,
int index,
CoreField field,
boolean mayShorten)
Retrieve a large binary object (byte array) for a specified object field.
|
protected Boolean |
getBooleanValue(ResultSet result,
int index,
CoreField field)
Retrieve a boolean value for a specified object field.
|
protected String |
getConstraintDefinition(CoreField field)
Creates an index definition string for a field to be passed when creating a table.
|
protected Date |
getDateTimeValue(ResultSet result,
int index,
CoreField field)
Retrieve a date for a specified object field.
|
DatabaseStorageManagerFactory |
getFactory() |
protected String |
getFieldDefinition(CoreField field)
Creates a fielddefinition, of the format '[fieldname] [fieldtype] NULL' or
'[fieldname] [fieldtype] NOT NULL' (depending on whether the field is nullable).
|
Map<CoreField,Integer> |
getFieldIndices(MMObjectBuilder builder,
StepField... fields) |
protected String |
getFieldList(Index index)
Returns a comma seperated list of fieldnames for an index.
|
String |
getFieldTypeDefinition(CoreField field)
Creates a field type definition, of the format '[fieldtype] NULL' or
'[fieldtype] NOT NULL' (depending on whether the field is nullable).
|
InputStream |
getInputStreamValue(MMObjectNode node,
CoreField field) |
protected int |
getJDBCtoField(int jdbcType,
int mmbaseType)
Guess the (mmbase) type in storage using the JDBC type.
|
protected long |
getLogStartTime() |
protected int |
getMaxLengthForKey(CoreField field) |
MMObjectNode |
getNode(MMObjectBuilder builder,
int number)
Select a node from a specified builder
|
int |
getNodeType(int number)
Returns the nodetype for a specified nodereference
|
String |
getStringValue(MMObjectNode node,
CoreField field)
Retrieve a large text for a specified object field.
|
protected Object |
getStringValue(ResultSet result,
int index,
CoreField field,
boolean mayShorten)
Retrieve a text for a specified object field.
|
Object |
getValue(ResultSet result,
int index,
CoreField field,
boolean mayShorten)
Attempts to return a single field value from the resultset of a query.
|
double |
getVersion()
Returns the version of this factory implementation.
|
protected Document |
getXMLValue(ResultSet result,
int index,
CoreField field,
boolean mayShorten)
Retrieve the XML (as a string) for a specified object field.
|
void |
init(DatabaseStorageManagerFactory factory)
Initializes the manager.
|
protected boolean |
isBinaryColumnType(int st)
Sometimes (legacy) string were stored in binary fields.
|
boolean |
isNull(MMObjectNode node,
CoreField field)
Checks for null values for a field from the storage of this builder.
|
protected boolean |
isPartOfBuilderDefinition(CoreField field)
Determines whether the storage should make a field definition in a builder table for a
specified field.
|
boolean |
isVerified(MMObjectBuilder builder)
Check if builders are already verified with the database.
|
protected boolean |
logQuery(String query,
long startTime) |
MMObjectNode |
readNode(MMObjectBuilder builder,
Map<CoreField,Integer> fieldIndices,
ResultSet rs,
boolean isVirtual) |
protected void |
refresh(MMObjectNode node)
Reloads the data from a node from the database.
|
protected void |
releaseActiveConnection()
Safely closes the active connection.
|
boolean |
rollback()
Cancels any transaction that was started and rollback changes if possible.
|
protected void |
setBinaryValue(PreparedStatement statement,
int index,
Object objectValue,
CoreField field,
MMObjectNode node)
Store binary data of a field in a prepared statement.
|
protected void |
setBooleanValue(PreparedStatement statement,
int index,
Object value,
CoreField field,
MMObjectNode node)
Store a boolean value of a field in a prepared statement.
|
protected void |
setDateTimeValue(PreparedStatement statement,
int index,
Object value,
CoreField field,
MMObjectNode node)
Store a Date value of a field in a prepared statement.
|
protected void |
setDecimalValue(PreparedStatement statement,
int index,
Object value,
CoreField field,
MMObjectNode node) |
protected void |
setListValue(PreparedStatement statement,
int index,
Object value,
CoreField field,
MMObjectNode node)
Store a List value of a field in a prepared statement.
|
int |
setNodeType(MMObjectNode node,
MMObjectBuilder bul) |
protected void |
setNodeTypeLeaveRelations(MMObjectNode node,
MMObjectBuilder buil)
Deletes the node, and recreates it in a different table.
|
protected void |
setNodeTypeRememberRelations(MMObjectNode node,
MMObjectBuilder buil)
Deletes the node, and recreates it in a different table.
|
protected void |
setNodeValue(PreparedStatement statement,
int index,
Object nodeValue,
CoreField field,
MMObjectNode node)
Store a node value of a field in a prepared statement
Nodes are stored in the database as numeric values.
|
protected boolean |
setNullValue(PreparedStatement statement,
int index,
Object value,
CoreField field,
int type)
Stores the 'null' value in the statement if appopriate (the value is null or unset, and the
value may indeed be NULL, according to the configuration).
|
protected void |
setNumericValue(PreparedStatement statement,
int index,
Object value,
CoreField field,
MMObjectNode node)
Store a numeric value of a field in a prepared statement
The method uses the Casting class to convert to the appropriate value.
|
protected Object |
setStringValue(PreparedStatement statement,
int index,
Object objectValue,
CoreField field,
MMObjectNode node)
Store the text value of a field in a prepared statement.
|
protected void |
setValue(PreparedStatement statement,
int index,
MMObjectNode node,
CoreField field)
Store the value of a field in a prepared statement
|
protected void |
setXMLValue(PreparedStatement statement,
int index,
Object objectValue,
CoreField field,
MMObjectNode node)
This default implementation calls
setStringValue(java.sql.PreparedStatement, int, java.lang.Object, org.mmbase.core.CoreField, org.mmbase.module.core.MMObjectNode). |
protected boolean |
shorten(CoreField field)
Determine whether a field (such as a large text or a blob) should be shortened or not.
|
int |
size()
Return the total number of objects in the storage
|
int |
size(MMObjectBuilder builder)
Return the number of objects of a builder in the storage
|
protected void |
storeBinaryAsFile(MMObjectNode node,
CoreField field)
Store a binary (blob) data file
|
protected boolean |
tablesInheritFields()
Returns whether tables inherit fields form parent tables.
|
protected void |
unloadShortedFields(MMObjectNode node,
MMObjectBuilder builder) |
protected boolean |
useDatabaseInheritance()
Whether during the table verification also metaData.getSuperTables must be used to obtain the fields in the
parent builder.
|
void |
verify(MMObjectBuilder builder)
Tests whether a builder and the table present in the database match.
|
protected boolean |
verifyTables() |
public static final int OBJ2TYPE_MAX_SIZE
protected static Cache<Integer,Integer> typeCache
protected DatabaseStorageManagerFactory factory
protected Connection activeConnection
releaseActiveConnection()protected boolean inTransaction
true if a transaction has been started.
This member is for state maitenance and may be true even if the storage does not support transactionsprotected int transactionIsolation
Attributes.TRANSACTION_ISOLATION_LEVEL attribute, which is commonly set
to the highest (most secure) transaction isolation level available.protected final Map<MMObjectNode,String> changes
protected final long getLogStartTime()
protected final boolean logQuery(String query, long startTime)
public double getVersion()
StorageManagergetVersion in interface StorageManager<DatabaseStorageManagerFactory>public void init(DatabaseStorageManagerFactory factory) throws StorageException
StorageManagerinit in interface StorageManager<DatabaseStorageManagerFactory>factory - the StorageManagerFactory instance that created this storage manager.StorageConfigurationException - if the initialization failedStorageExceptionpublic DatabaseStorageManagerFactory getFactory()
protected boolean verifyTables()
protected Connection getActiveConnection() throws SQLException
activeConnection member.
If an active connection was allready open, and the manager is in a database transaction, that connection is returned instead.
Otherwise, the connection is closed before a new one is opened.SQLException - if opening the connection failedprotected void releaseActiveConnection()
public void beginTransaction()
throws StorageException
StorageManagerbeginTransaction in interface StorageManager<DatabaseStorageManagerFactory>StorageException - if the transaction could not be createdpublic void commit()
throws StorageException
StorageManagercommit in interface StorageManager<DatabaseStorageManagerFactory>StorageException - if a transaction is not currently active, or an error occurred while committingpublic boolean rollback()
throws StorageException
StorageManagerrollback in interface StorageManager<DatabaseStorageManagerFactory>true if changes were rolled back, false if the transaction was
canceled but the storage does not support rollbackStorageException - if a transaction is not currently active, or an error occurred during rollbackprotected void commitChange(MMObjectNode node, String change)
changes object (to be committed after the transaction ends).
Otherwise it directly commits and broadcasts the changesnode - the node to registerchange - the type of change: "n": new, "c": commit, "d": delete, "r" : relation changedpublic int createKey()
throws StorageException
StorageManagercreateKey in interface StorageManager<DatabaseStorageManagerFactory>StorageExceptionpublic String getStringValue(MMObjectNode node, CoreField field) throws StorageException
StorageManagergetStringValue in interface StorageManager<DatabaseStorageManagerFactory>node - the node to retrieve the text fromfield - the Type of the field to retrieveStorageException - if an error occurred while retrieving the text valueprotected boolean isBinaryColumnType(int st)
protected Object getStringValue(ResultSet result, int index, CoreField field, boolean mayShorten) throws StorageException, SQLException
ResultSet.getString(int) to obtain text.
Override this method if you want to optimize retrieving large texts,
i.e by using clobs or streams.result - the resultset to retrieve the text fromindex - the index of the text in the resultsetfield - the (MMBase) fieldtype. This value can be nullnull if no text was storedSQLException - when a database error occursStorageException - when data is incompatible or the function is not supportedprotected Document getXMLValue(ResultSet result, int index, CoreField field, boolean mayShorten) throws StorageException, SQLException
ResultSet.getString(int) to obtain text.
Unlike
Override this method if you want to optimize retrieving large texts,
i.e by using clobs or streams.result - the resultset to retrieve the xml fromindex - the index of the xml in the resultsetfield - the (MMBase) fieldtype. This value can be nullnull if nothing was storedSQLException - when a database error occursStorageException - when data is incompatible or the function is not supportedprotected Date getDateTimeValue(ResultSet result, int index, CoreField field) throws StorageException, SQLException
ResultSet.getTimestamp(int) to obtain the date.result - the resultset to retrieve the value fromindex - the index of the value in the resultsetfield - the (MMBase) fieldtype. This value can be nullnull if no text was storedSQLException - when a database error occursStorageException - when data is incompatible or the function is not supportedprotected Boolean getBooleanValue(ResultSet result, int index, CoreField field) throws StorageException, SQLException
ResultSet.getBoolean(int) to obtain the date.result - the resultset to retrieve the value fromindex - the index of the value in the resultsetfield - the (MMBase) fieldtype. This value can be nullnull if no text was storedSQLException - when a database error occursStorageException - when data is incompatible or the function is not supportedprotected boolean shorten(CoreField field)
getStringValue(MMObjectNode, CoreField) or.
getBinaryValue(MMObjectNode, CoreField).
The default implementation returns true for binaries, and false for other
types.
Override this method if you want to be able to change the placeholder strategy.field - the (MMBase) fieldtypetrue if the field should be shortenedStorageException - when data is incompatible or the function is not supportedprotected Blob getBlobFromDatabase(MMObjectNode node, CoreField field, boolean mayShorten)
node - the node the binary data belongs tofield - the binary fieldnull if no binary data was stored, or VALUE_SHORTED, if mayShortenpublic byte[] getBinaryValue(MMObjectNode node, CoreField field) throws StorageException
StorageManagergetBinaryValue in interface StorageManager<DatabaseStorageManagerFactory>node - the node to retrieve the byte array fromfield - the CoreField of the field to retrieveStorageException - if an error occurred while retrieving the binary valueStorageManager.getBinaryValue(org.mmbase.module.core.MMObjectNode, org.mmbase.core.CoreField)public InputStream getInputStreamValue(MMObjectNode node, CoreField field) throws StorageException
getInputStreamValue in interface StorageManager<DatabaseStorageManagerFactory>StorageExceptionStorageManager.getInputStreamValue(org.mmbase.module.core.MMObjectNode, org.mmbase.core.CoreField)public Blob getBlobValue(MMObjectNode node, CoreField field) throws StorageException
StorageExceptionpublic Blob getBlobValue(MMObjectNode node, CoreField field, boolean mayShorten) throws StorageException
StorageExceptionprotected Blob getBlobValue(ResultSet result, int index, CoreField field, boolean mayShorten) throws StorageException, SQLException
ResultSet.getBytes(int) to obtain text.
Override this method if you want to optimize retrieving large objects,
i.e by using clobs or streams.result - the resultset to retrieve the text fromindex - the index of the text in the resultset, or -1 to retireiv from file (blobs).field - the (MMBase) fieldtype. This value can be nullnull if no binary data was storedSQLException - when a database error occursStorageException - when data is incompatible or the function is not supportedpublic static StringBuilder appendDirectory(StringBuilder pathBuffer, int number, String separator)
protected File getBinaryFile(MMObjectNode node, String fieldName)
node - the node the binary data belongs tofieldName - the name of the binary fieldprotected void storeBinaryAsFile(MMObjectNode node, CoreField field) throws StorageException
node - the node the binary data belongs tofield - the binary fieldStorageException - when an error occured while a binary is written to fileprotected File checkFile(File binaryFile, MMObjectNode node, CoreField field)
binaryFile - file location of binarynode - the binary is a field value of this nodefield - field of the nodenull if no existing readable file could be found, also no 'legacy' one.public int create(MMObjectNode node) throws StorageException
StorageManagercreate in interface StorageManager<DatabaseStorageManagerFactory>node - The node to insertStorageException - if an error occurred during insertStorageManager.create(org.mmbase.module.core.MMObjectNode)protected void create(MMObjectNode node, MMObjectBuilder builder) throws StorageException
node - The node to insert. The node already needs to have a (new) number assignedbuilder - the builder to store the nodeStorageException - if an error occurred during creationprotected void appendField(StringBuilder fieldNames, StringBuilder fieldValues, CoreField field)
protected void create(MMObjectNode node, List<CoreField> createFields, String tablename)
protected void unloadShortedFields(MMObjectNode node, MMObjectBuilder builder)
protected int executeUpdateCheckConnection(String query, MMObjectNode node, List<CoreField> fields) throws SQLException
SQLException - If something wrong with the query, or the database is down or could not be contacted.protected int executeUpdate(String query, MMObjectNode node, List<CoreField> fields) throws SQLException
executeUpdateCheckConnection(java.lang.String, org.mmbase.module.core.MMObjectNode, java.util.List<org.mmbase.core.CoreField>) which in turn is called from
several spots in this class.query - update querynode - updated nodefields - updated fieldsSQLException - if database connections failures occurspublic void change(MMObjectNode node) throws StorageException
StorageManagerchange in interface StorageManager<DatabaseStorageManagerFactory>node - The node to commitStorageException - if an error occurred during commitprotected void change(MMObjectNode node, MMObjectBuilder builder) throws StorageException
node - The node to changebuilder - the builder to store the nodeStorageException - if an error occurred during changeprotected void change(MMObjectNode node, MMObjectBuilder builder, String tableName, Collection<CoreField> changeFields)
protected void setValue(PreparedStatement statement, int index, MMObjectNode node, CoreField field) throws StorageException, SQLException
statement - the prepared statementindex - the index of the field in the prepared statementnode - the node from which to retrieve the valuefield - the MMBase field, containing meta-informationStorageException - if the fieldtype is invalid, or data is invalid or missingSQLException - if an error occurred while filling in the fieldsprotected boolean setNullValue(PreparedStatement statement, int index, Object value, CoreField field, int type) throws StorageException, SQLException
statement - the prepared statementindex - the index of the field in the prepared statementvalue - the numeric value to store, which will be checked for null.field - the MMBase field, containing meta-informationStorageException - if the data is invalid or missingSQLException - if an error occurred while filling in the fieldsprotected void setNumericValue(PreparedStatement statement, int index, Object value, CoreField field, MMObjectNode node) throws StorageException, SQLException
statement - the prepared statementindex - the index of the field in the prepared statementvalue - the numeric value to store. This may be a String, MMObjectNode, Numeric, or other value - the
method will convert it to the appropriate value.field - the MMBase field, containing meta-informationnode - the node that contains the data. Used to update this node if the database layer makes changes
to the data (i.e. creating a default value for a non-null field that had a null value)StorageException - if the data is invalid or missingSQLException - if an error occurred while filling in the fieldsprotected void setNodeValue(PreparedStatement statement, int index, Object nodeValue, CoreField field, MMObjectNode node) throws StorageException, SQLException
statement - the prepared statementindex - the index of the field in the prepared statementnodeValue - the node to storefield - the MMBase field, containing meta-informationnode - the node that contains the data.StorageException - if the data is invalid or missingSQLException - if an error occurred while filling in the fieldsprotected void setBooleanValue(PreparedStatement statement, int index, Object value, CoreField field, MMObjectNode node) throws StorageException, SQLException
false
Override this method if you use another way to store booleansstatement - the prepared statementindex - the index of the field in the prepared statementvalue - the data (boolean) to storefield - the MMBase field, containing meta-informationnode - the node that contains the data. Used to update this node if the database layer makes changes
to the data (i.e. creating a default value for a non-null field that had a null value)StorageException - if the data is invalid or missingSQLException - if an error occurred while filling in the fieldsprotected void setDateTimeValue(PreparedStatement statement, int index, Object value, CoreField field, MMObjectNode node) throws StorageException, SQLException
statement - the prepared statementindex - the index of the field in the prepared statementvalue - the data (date) to storefield - the MMBase field, containing meta-informationnode - the node that contains the data. Used to update this node if the database layer makes changes
to the data (i.e. creating a default value for a non-null field that had a null value)StorageException - if the data is invalid or missingSQLException - if an error occurred while filling in the fieldsprotected void setDecimalValue(PreparedStatement statement, int index, Object value, CoreField field, MMObjectNode node) throws StorageException, SQLException
StorageExceptionSQLExceptionprotected void setListValue(PreparedStatement statement, int index, Object value, CoreField field, MMObjectNode node) throws StorageException, SQLException
statement - the prepared statementindex - the index of the field in the prepared statementvalue - the data (List) to storefield - the MMBase field, containing meta-information. This value can be nullnode - the node that contains the data. Used to update this node if the database layer makes changes
to the data (i.e. creating a default value for a non-null field that had a null value)StorageException - if the data is invalid or missingSQLException - if an error occurred while filling in the fieldsprotected void setBinaryValue(PreparedStatement statement, int index, Object objectValue, CoreField field, MMObjectNode node) throws StorageException, SQLException
statement - the prepared statementindex - the index of the field in the prepared statementobjectValue - the data (byte array) to storefield - the MMBase field, containing meta-informationnode - the node that contains the data. Used to update this node if the database layer makes changes
to the data (i.e. creating a default value for a non-null field that had a null value)StorageException - if the data is invalid or missingSQLException - if an error occurred while filling in the fieldsprotected Object setStringValue(PreparedStatement statement, int index, Object objectValue, CoreField field, MMObjectNode node) throws StorageException, SQLException
PreparedStatement.setString(int, String) to set the data.
Override this method if you use another way to store large texts (i.e. Clobs).statement - the prepared statementindex - the index of the field in the prepared statementobjectValue - the text to storefield - the MMBase field, containing meta-informationnode - the node that contains the data.StorageException - if the data is invalid or missingSQLException - if an error occurred while filling in the fieldsprotected void setXMLValue(PreparedStatement statement, int index, Object objectValue, CoreField field, MMObjectNode node) throws StorageException, SQLException
setStringValue(java.sql.PreparedStatement, int, java.lang.Object, org.mmbase.core.CoreField, org.mmbase.module.core.MMObjectNode).
Override this method if you want to override this behavior.statement - prepared update statementindex - index in statement to set the value inobjectValue - value to setfield - update of this node fieldnode - updated nodeStorageException - error occured in storage layerSQLException - if database connections failures occurspublic void delete(MMObjectNode node) throws StorageException
StorageManagerdelete in interface StorageManager<DatabaseStorageManagerFactory>node - The node to deleteStorageException - if an error occurred during deleteStorageManager.delete(org.mmbase.module.core.MMObjectNode)public Map<CoreField,Integer> getFieldIndices(MMObjectBuilder builder, StepField... fields)
public MMObjectNode readNode(MMObjectBuilder builder, Map<CoreField,Integer> fieldIndices, ResultSet rs, boolean isVirtual) throws SQLException
SQLExceptionprotected void setNodeTypeRememberRelations(MMObjectNode node, MMObjectBuilder buil) throws StorageException
StorageExceptionprotected void setNodeTypeLeaveRelations(MMObjectNode node, MMObjectBuilder buil) throws StorageException
StorageExceptionpublic int setNodeType(MMObjectNode node, MMObjectBuilder bul) throws StorageException
setNodeType in interface StorageManager<DatabaseStorageManagerFactory>StorageExceptionprotected void delete(MMObjectNode node, MMObjectBuilder builder) throws StorageException
node - The node to deleteStorageException - if an error occurred during deleteprotected void delete(MMObjectNode node, MMObjectBuilder builder, List<CoreField> blobFileField, String tablename)
public MMObjectNode getNode(MMObjectBuilder builder, int number) throws StorageException
StorageManagergetNode in interface StorageManager<DatabaseStorageManagerFactory>builder - The builder to select fromnumber - the number of the nodeStorageException - if an error occurred during the getStorageManager.getNode(org.mmbase.module.core.MMObjectBuilder, int)protected void refresh(MMObjectNode node) throws StorageException
node - the node to refreshStorageException - error occurred in storage layerprotected void fillNode(MMObjectNode node, ResultSet result, MMObjectBuilder builder) throws StorageException
result.isAfterLast returns false)node - The MMObjectNode to be filledresult - the resultsetbuilder - the builder to use for creating the nodeStorageException - if the resultset is exhausted or a database error occurredpublic Object getValue(ResultSet result, int index, CoreField field, boolean mayShorten) throws StorageException
result - the resultsetindex - the index of the field in the resultsetfield - the expected MMBase field type. This can be nullmayShorten - Whether it would suffice to return only a 'shorted' version of the value.StorageException - if the value cannot be retrieved from the resultsetpublic int getNodeType(int number)
throws StorageException
StorageManagergetNodeType in interface StorageManager<DatabaseStorageManagerFactory>number - the number of the nodeStorageException - if an error occurred during selectionStorageManager.getNodeType(int)protected boolean tablesInheritFields()
true,protected boolean useDatabaseInheritance()
protected boolean isPartOfBuilderDefinition(CoreField field)
field - public void create(MMObjectBuilder builder) throws StorageException
StorageManagercreate in interface StorageManager<DatabaseStorageManagerFactory>builder - the builder to create the storage element forStorageException - if an error occurred during the creation of the storage elementStorageManager.create(org.mmbase.module.core.MMObjectBuilder)protected void createTable(MMObjectBuilder builder, List<CoreField> tableFields, String tableName)
protected void addToTableNameCache(String name)
public String getFieldTypeDefinition(CoreField field) throws StorageException
field - the fieldStorageException - if the field type cannot be mappedprotected String getFieldDefinition(CoreField field) throws StorageException
field - the fieldStorageException - if the field type cannot be mappedprotected int getMaxLengthForKey(CoreField field)
protected String getConstraintDefinition(CoreField field) throws StorageException
field - the field for which to make the index definitionnull if no definition is availableStorageExceptionpublic void change(MMObjectBuilder builder) throws StorageException
StorageManagerchange in interface StorageManager<DatabaseStorageManagerFactory>builder - the builder whose storage to changeStorageExceptionpublic void delete(MMObjectBuilder builder) throws StorageException
StorageManagerdelete in interface StorageManager<DatabaseStorageManagerFactory>builder - the builder whose storage to dropStorageExceptionpublic void create()
throws StorageException
StorageManagercreate in interface StorageManager<DatabaseStorageManagerFactory>StorageException - if an error occurred during the creation of the object storageprotected void createSequence()
throws StorageException
createKey().StorageException - when the sequence can not be createdpublic boolean exists(MMObjectBuilder builder) throws StorageException
StorageManagerexists in interface StorageManager<DatabaseStorageManagerFactory>builder - the builder to checktrue if the storage element exists, false if it doesn'tStorageException - if an error occurred while querying the storageprotected boolean exists(String tableName) throws StorageException
tableName - name of the table to look fortrue if the table existsStorageException - when the metadata could not be retrievedpublic boolean exists()
throws StorageException
StorageManagerexists in interface StorageManager<DatabaseStorageManagerFactory>true if basic storage elements existStorageException - if an error occurred while querying the storagepublic int size(MMObjectBuilder builder) throws StorageException
StorageManagersize in interface StorageManager<DatabaseStorageManagerFactory>builder - the builder whose objects to countStorageException - if the storage element for the builder does not existspublic int size()
throws StorageException
StorageManagersize in interface StorageManager<DatabaseStorageManagerFactory>StorageException - if the basic storage elements do not existprotected int getJDBCtoField(int jdbcType,
int mmbaseType)
public boolean isVerified(MMObjectBuilder builder)
builder - Builder which might be verifiedtrue when already verifiedpublic void verify(MMObjectBuilder builder) throws StorageException
StorageExceptionprotected boolean compareIndex(List<String> indexFields, Index index)
protected boolean exists(Index index, String tablename)
index - the index to testtablename - the tablename to test the index againstStorageException - when a database error occursprotected boolean exists(Index index) throws StorageException
index - the index to testStorageException - when a database error occursprotected void deleteIndices(CoreField field) throws StorageException
field - the field for which to drop indicesStorageException - when a database error occursprotected void delete(Index index) throws StorageException
index - the index to dropStorageException - when a database error occursprotected String getFieldList(Index index)
index - the index to create it fornull if the index was empty, or
if it consists of a composite index and composite indices are not supported.protected void createIndices(CoreField field) throws StorageException
field - the field for which to create indicesStorageException - when a database error occursprotected void create(Index index) throws StorageException
index - the index to createStorageExceptionprotected void createIndex(Index index, String tablename)
index - the index to createtablename - name of the tablepublic void create(CoreField field) throws StorageException
StorageManagercreate in interface StorageManager<DatabaseStorageManagerFactory>field - the CoreField of the field to addStorageExceptionStorageManager.create(org.mmbase.core.CoreField)public void change(CoreField field) throws StorageException
StorageManagerchange in interface StorageManager<DatabaseStorageManagerFactory>field - the CoreField of the field to changeStorageExceptionStorageManager.change(org.mmbase.core.CoreField)public void delete(CoreField field) throws StorageException
StorageManagerdelete in interface StorageManager<DatabaseStorageManagerFactory>field - the CoreField of the field to deleteStorageExceptionStorageManager.delete(org.mmbase.core.CoreField)public int convertLegacyBinaryFiles()
throws SearchQueryException,
SQLException
SearchQueryExceptionSQLException - if opening the connection failedpublic boolean isNull(MMObjectNode node, CoreField field) throws StorageException
StorageManagerisNull in interface StorageManager<DatabaseStorageManagerFactory>node - the node to check the value forfield - the CoreFieldtrue when value is null in storageStorageException - if an error occurred during the getStorageManager.isNull(org.mmbase.module.core.MMObjectNode, org.mmbase.core.CoreField)public void executeQuery(String sql, ResultSetReader reader) throws SQLException
SQLExceptionMMBase 1.9-SNAPSHOT - ${javadoctimestamp}