public class DefaultStatements extends Object implements Statements
Statements interface which applies to all databases.| Modifier and Type | Class and Description |
|---|---|
protected static interface |
DefaultStatements.BatchOperation<T> |
protected class |
DefaultStatements.DefaultBatchUpdate |
Statements.BatchUpdate| Modifier and Type | Field and Description |
|---|---|
protected Logger |
logger |
CONTENT_EXISTS, CREATE_TABLE, DELETE_TABLE, GET_ALL_IDS, GET_BY_ID, GET_MULTIPLE, INSERT_CONTENT, REMOVE_ALL_CONTENT, REMOVE_CONTENT, UPDATE_CONTENT| Modifier | Constructor and Description |
|---|---|
protected |
DefaultStatements(RelationalDbConfig config,
Map<String,String> statements) |
| Modifier and Type | Method and Description |
|---|---|
protected int |
batchLoadSize() |
DefaultStatements.DefaultBatchUpdate |
batchUpdate(Connection connection)
Starts a batch update operation with the given connection.
|
Void |
createTable(Connection connection)
Create a new table.
|
Void |
dropTable(Connection connection)
Drops a table.
|
boolean |
exists(Connection connection,
String id)
Checks if there is a document with the given id.
|
List<String> |
getAllIds(Connection connection)
Returns all the ids from a table.
|
Document |
getById(Connection connection,
String id)
Searches for a document with a certain id.
|
<R> List<R> |
load(Connection connection,
List<String> ids,
Function<Document,R> parser)
Loads multiple documents based on a set of ids.
|
protected void |
logTableInfo(String message) |
protected Document |
readDocument(InputStream is) |
Void |
removeAll(Connection connection)
Removes all the contents of a table.
|
protected String |
tableName() |
protected byte[] |
writeDocument(Document content) |
protected final Logger logger
protected DefaultStatements(RelationalDbConfig config, Map<String,String> statements)
public Void createTable(Connection connection) throws SQLException
StatementscreateTable in interface Statementsconnection - a Connection instance; may not be nullSQLException - if the operation fails.public Void dropTable(Connection connection) throws SQLException
StatementsdropTable in interface Statementsconnection - a Connection instance; may not be nullSQLException - if the operation fails.public List<String> getAllIds(Connection connection) throws SQLException
StatementsgetAllIds in interface Statementsconnection - a Connection instance; may not be nullList of ids; never nullSQLException - if the operation fails.public Document getById(Connection connection, String id) throws SQLException
StatementsgetById in interface Statementsconnection - a Connection instance; may not be nullDocument instance or null if the document is not found.SQLException - if the operation fails.public <R> List<R> load(Connection connection, List<String> ids, Function<Document,R> parser) throws SQLException
StatementsDepending on the type of DB, if a very large number of IDs is used this may have side effects:
load in interface Statementsconnection - a Connection instance; may not be nullids - a List of ids; may not be nullparser - a Function which is used to transform or process each of documents corresponding to the given IDS;
may not be nullList of Object instances for each of the ids which were found in the DB; never nullSQLException - if the operation fails.public DefaultStatements.DefaultBatchUpdate batchUpdate(Connection connection)
StatementsbatchUpdate in interface Statementsconnection - a Connection instance; may not be nullStatements.BatchUpdate instance, never nullpublic boolean exists(Connection connection, String id) throws SQLException
Statementsexists in interface Statementsconnection - a Connection instance; may not be nullid - a String the id of a document; may not be nulltrue if the document exists, false otherwise.SQLException - if the operation fails.public Void removeAll(Connection connection) throws SQLException
StatementsremoveAll in interface Statementsconnection - a Connection instance; may not be nullSQLException - if the operation fails.protected int batchLoadSize()
protected void logTableInfo(String message)
protected String tableName()
protected Document readDocument(InputStream is)
protected byte[] writeDocument(Document content)
Copyright © 2008–2016 JBoss, a division of Red Hat. All rights reserved.