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 byte[] |
writeDocument(Document content) |
protected final Logger logger
protected DefaultStatements(RelationalDbConfig config, Map<String,String> statements)
public Void createTable(Connection connection) throws SQLException
Statements
createTable
in interface Statements
connection
- a Connection
instance; may not be nullSQLException
- if the operation fails.public Void dropTable(Connection connection) throws SQLException
Statements
dropTable
in interface Statements
connection
- a Connection
instance; may not be nullSQLException
- if the operation fails.public List<String> getAllIds(Connection connection) throws SQLException
Statements
getAllIds
in interface Statements
connection
- a Connection
instance; may not be nullList
of ids; never null
SQLException
- if the operation fails.public Document getById(Connection connection, String id) throws SQLException
Statements
getById
in interface Statements
connection
- 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
Statements
Depending on the type of DB, if a very large number of IDs is used this may have side effects:
load
in interface Statements
connection
- 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 null
SQLException
- if the operation fails.public DefaultStatements.DefaultBatchUpdate batchUpdate(Connection connection)
Statements
batchUpdate
in interface Statements
connection
- a Connection
instance; may not be nullStatements.BatchUpdate
instance, never null
public boolean exists(Connection connection, String id) throws SQLException
Statements
exists
in interface Statements
connection
- 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
Statements
removeAll
in interface Statements
connection
- a Connection
instance; may not be nullSQLException
- if the operation fails.protected int batchLoadSize()
protected void logTableInfo(String message)
protected Document readDocument(InputStream is)
protected byte[] writeDocument(Document content)
Copyright © 2008–2016 JBoss, a division of Red Hat. All rights reserved.