@Deprecated public abstract class DatabasePersistenceManager extends AbstractPersistenceManager
getConnection()
method to return
the configured database connection.
See the SimpleDbPersistenceManager
for a detailed description
of the available configuration options and database behaviour.
Modifier and Type | Field and Description |
---|---|
protected boolean |
autoReconnect
Deprecated.
|
protected String |
blobDeleteSQL
Deprecated.
|
protected FileSystem |
blobFS
Deprecated.
file system where BLOB data is stored
(if
externalBLOBs==true ) |
protected String |
blobInsertSQL
Deprecated.
|
protected String |
blobSelectExistSQL
Deprecated.
|
protected String |
blobSelectSQL
Deprecated.
|
protected BLOBStore |
blobStore
Deprecated.
BLOBStore that manages BLOB data in the file system
(if
externalBLOBs==true ) |
protected String |
blobUpdateSQL
Deprecated.
|
protected Connection |
con
Deprecated.
|
protected boolean |
externalBLOBs
Deprecated.
|
protected static int |
INITIAL_BUFFER_SIZE
Deprecated.
|
protected boolean |
initialized
Deprecated.
|
protected String |
nodeReferenceDeleteSQL
Deprecated.
|
protected String |
nodeReferenceInsertSQL
Deprecated.
|
protected String |
nodeReferenceSelectExistSQL
Deprecated.
|
protected String |
nodeReferenceSelectSQL
Deprecated.
|
protected String |
nodeReferenceUpdateSQL
Deprecated.
|
protected String |
nodeStateDeleteSQL
Deprecated.
|
protected String |
nodeStateInsertSQL
Deprecated.
|
protected String |
nodeStateSelectExistSQL
Deprecated.
|
protected String |
nodeStateSelectSQL
Deprecated.
|
protected String |
nodeStateUpdateSQL
Deprecated.
|
protected String |
propertyStateDeleteSQL
Deprecated.
|
protected String |
propertyStateInsertSQL
Deprecated.
|
protected String |
propertyStateSelectExistSQL
Deprecated.
|
protected String |
propertyStateSelectSQL
Deprecated.
|
protected String |
propertyStateUpdateSQL
Deprecated.
|
protected String |
schema
Deprecated.
|
protected static String |
SCHEMA_OBJECT_PREFIX_VARIABLE
Deprecated.
|
protected String |
schemaObjectPrefix
Deprecated.
|
protected static int |
SLEEP_BEFORE_RECONNECT
Deprecated.
|
Constructor and Description |
---|
DatabasePersistenceManager()
Deprecated.
Creates a new
DatabasePersistenceManager instance. |
Modifier and Type | Method and Description |
---|---|
protected void |
buildSQLStatements()
Deprecated.
Builds the SQL statements
|
protected void |
checkSchema()
Deprecated.
Checks if the required schema objects exist and creates them if they
don't exist yet.
|
void |
close()
Deprecated.
Closes the persistence manager.
|
protected void |
closeConnection(Connection connection)
Deprecated.
Closes the given database connection.
|
protected void |
closeResultSet(ResultSet rs)
Deprecated.
|
protected void |
closeStatement(Statement stmt)
Deprecated.
|
protected String |
createSchemaSql(String sql)
Deprecated.
Replace wildcards and return the expanded SQL statement.
|
void |
destroy(NodeReferences refs)
Deprecated.
Destroy a node references object.
|
void |
destroy(NodeState state)
Deprecated.
Destroy a node state.
|
void |
destroy(PropertyState state)
Deprecated.
Destroy a property state.
|
protected Statement |
executeStmt(String sql,
Object[] params)
Deprecated.
Executes the given SQL statement with the specified parameters.
|
boolean |
exists(NodeId id)
Deprecated.
Checks whether the identified node exists.
|
boolean |
exists(PropertyId id)
Deprecated.
Checks whether the identified property exists.
|
boolean |
existsReferencesTo(NodeId targetId)
Deprecated.
Checks whether references of the identified target node exist.
|
protected Connection |
getConnection()
Deprecated.
Abstract factory method for creating a new database connection.
|
String |
getSchema()
Deprecated.
|
protected InputStream |
getSchemaDDL()
Deprecated.
Returns an input stream to the schema DDL resource.
|
String |
getSchemaObjectPrefix()
Deprecated.
|
void |
init(PMContext context)
Deprecated.
Initializes the persistence manager.
|
protected void |
initConnection()
Deprecated.
Initializes the database connection used by this persistence manager.
|
protected void |
initPreparedStatements()
Deprecated.
Initializes the map of prepared statements.
|
boolean |
isExternalBLOBs()
Deprecated.
|
boolean |
isSchemaCheckEnabled()
Deprecated.
|
NodeState |
load(NodeId id)
Deprecated.
Load the persistent members of a node state.
|
PropertyState |
load(PropertyId id)
Deprecated.
Load the persistent members of a property state.
|
NodeReferences |
loadReferencesTo(NodeId targetId)
Deprecated.
Load the persisted references to the node with the given identifier.
|
protected void |
logException(String message,
SQLException se)
Deprecated.
|
protected void |
prepareSchemaObjectPrefix()
Deprecated.
Makes sure that
schemaObjectPrefix does only consist of
characters that are allowed in names on the target database. |
protected boolean |
reestablishConnection()
Deprecated.
Re-establishes the database connection.
|
protected void |
resetStatement(PreparedStatement stmt)
Deprecated.
Resets the given
PreparedStatement by clearing the parameters
and warnings contained. |
void |
setExternalBLOBs(boolean externalBLOBs)
Deprecated.
|
void |
setExternalBLOBs(String externalBLOBs)
Deprecated.
|
void |
setSchema(String schema)
Deprecated.
|
void |
setSchemaCheckEnabled(boolean enabled)
Deprecated.
|
void |
setSchemaObjectPrefix(String schemaObjectPrefix)
Deprecated.
|
void |
store(ChangeLog changeLog)
Deprecated.
Right now, this iterates over all items in the changelog and
calls the individual methods that handle single item states
or node references objects.
|
void |
store(NodeReferences refs)
Deprecated.
Store a references object.
|
void |
store(NodeState state)
Deprecated.
Store a node state.
|
void |
store(PropertyState state)
Deprecated.
Store a property state.
|
checkConsistency, createNew, createNew
protected static final String SCHEMA_OBJECT_PREFIX_VARIABLE
protected boolean initialized
protected String schema
protected String schemaObjectPrefix
protected boolean externalBLOBs
protected static final int INITIAL_BUFFER_SIZE
protected Connection con
protected boolean autoReconnect
protected static final int SLEEP_BEFORE_RECONNECT
protected String nodeStateInsertSQL
protected String nodeStateUpdateSQL
protected String nodeStateSelectSQL
protected String nodeStateSelectExistSQL
protected String nodeStateDeleteSQL
protected String propertyStateInsertSQL
protected String propertyStateUpdateSQL
protected String propertyStateSelectSQL
protected String propertyStateSelectExistSQL
protected String propertyStateDeleteSQL
protected String nodeReferenceInsertSQL
protected String nodeReferenceUpdateSQL
protected String nodeReferenceSelectSQL
protected String nodeReferenceSelectExistSQL
protected String nodeReferenceDeleteSQL
protected String blobInsertSQL
protected String blobUpdateSQL
protected String blobSelectSQL
protected String blobSelectExistSQL
protected String blobDeleteSQL
protected FileSystem blobFS
externalBLOBs==true
)protected BLOBStore blobStore
externalBLOBs==true
)public DatabasePersistenceManager()
DatabasePersistenceManager
instance.public String getSchemaObjectPrefix()
public void setSchemaObjectPrefix(String schemaObjectPrefix)
public String getSchema()
public void setSchema(String schema)
public boolean isExternalBLOBs()
public void setExternalBLOBs(boolean externalBLOBs)
public void setExternalBLOBs(String externalBLOBs)
public final boolean isSchemaCheckEnabled()
public final void setSchemaCheckEnabled(boolean enabled)
enabled
- set whether the schema check is enabledpublic void init(PMContext context) throws Exception
An appropriate exception is thrown if the persistence manager initialization fails for whatever reason. In this case the state of the persistence manager is undefined and the instance should be discarded.
context
- persistence manager contextException
- if the persistence manager initialization failedpublic void close() throws Exception
An appropriate exception is thrown if the persistence manager could not be closed properly. In this case the state of the persistence manager is undefined and the instance should be discarded.
Exception
- if the persistence manager failed to close properlypublic void store(ChangeLog changeLog) throws ItemStateException
store
in interface PersistenceManager
store
in class AbstractPersistenceManager
changeLog
- change log containing states that were changedItemStateException
- if the changes could not be savedpublic NodeState load(NodeId id) throws NoSuchItemStateException, ItemStateException
id
- node idNoSuchItemStateException
- if the node state does not existItemStateException
- if another error occurspublic PropertyState load(PropertyId id) throws NoSuchItemStateException, ItemStateException
id
- property idNoSuchItemStateException
- if the property state does not existItemStateException
- if another error occurspublic void store(NodeState state) throws ItemStateException
This method uses shared PreparedStatement
s which must
be executed strictly sequentially. Because this method synchronizes on
the persistence manager instance there is no need to synchronize on the
shared statement. If the method would not be synchronized the shared
statements would have to be synchronized.
store
in class AbstractPersistenceManager
state
- node state to storeItemStateException
- if an error occurspublic void store(PropertyState state) throws ItemStateException
This method uses shared PreparedStatement
s which must
be executed strictly sequentially. Because this method synchronizes on
the persistence manager instance there is no need to synchronize on the
shared statement. If the method would not be synchronized the shared
statements would have to be synchronized.
store
in class AbstractPersistenceManager
state
- property state to storeItemStateException
- if an error occurspublic void destroy(NodeState state) throws ItemStateException
destroy
in class AbstractPersistenceManager
state
- node state to destroyItemStateException
- if an error occurspublic void destroy(PropertyState state) throws ItemStateException
destroy
in class AbstractPersistenceManager
state
- property state to destroyItemStateException
- if an error occurspublic NodeReferences loadReferencesTo(NodeId targetId) throws NoSuchItemStateException, ItemStateException
targetId
- reference target node idNoSuchItemStateException
- if the target node does not existItemStateException
- if another error occurspublic void store(NodeReferences refs) throws ItemStateException
This method uses shared PreparedStatement
s which must
be executed strictly sequentially. Because this method synchronizes on
the persistence manager instance there is no need to synchronize on the
shared statement. If the method would not be synchronized the shared
statements would have to be synchronized.
store
in class AbstractPersistenceManager
refs
- references object to storeItemStateException
- if an error occurspublic void destroy(NodeReferences refs) throws ItemStateException
destroy
in class AbstractPersistenceManager
refs
- node references object to destroyItemStateException
- if an error occurspublic boolean exists(NodeId id) throws ItemStateException
id
- node idtrue
if the node exists,
false
otherwiseItemStateException
- on persistence manager errorspublic boolean exists(PropertyId id) throws ItemStateException
id
- property idtrue
if the property exists,
false
otherwiseItemStateException
- on persistence manager errorspublic boolean existsReferencesTo(NodeId targetId) throws ItemStateException
targetId
- target node idtrue
if the references exist,
false
otherwiseItemStateException
- on persistence manager errorsprotected void initConnection() throws Exception
Subclasses should normally override the getConnection()
method instead of this one. The default implementation calls
getConnection()
to get the database connection and disables
the autocommit feature.
Exception
- if an error occursprotected Connection getConnection() throws Exception
init(PMContext)
when the persistence
manager is started. The returned connection should come with the default
JDBC settings, as the init(PMContext)
method will explicitly
set the autoCommit
and other properties as needed.
Note that the returned database connection is kept during the entire
lifetime of the persistence manager, after which it is closed by
close()
using the closeConnection(Connection)
method.
Exception
- if an error occursprotected void closeConnection(Connection connection) throws Exception
close()
to close the connection acquired using
getConnection()
when the persistence manager was started.
The default implementation just calls the Connection.close()
method of the given connection, but subclasses can override this
method to provide more extensive database and connection cleanup.
connection
- database connectionException
- if an error occursprotected boolean reestablishConnection()
store(ChangeLog)
and executeStmt(String, Object[])
after a SQLException
had been encountered.protected Statement executeStmt(String sql, Object[] params) throws SQLException
SQLException
is encountered and
autoReconnect==true
one attempt is made to re-establish
the database connection and re-execute the statement.sql
- statement to executeparams
- parameters to setStatement
object that had been executedSQLException
- if an error occursprotected void resetStatement(PreparedStatement stmt)
PreparedStatement
by clearing the parameters
and warnings contained.
NOTE: This method MUST be called in a synchronized context as neither
this method nor the PreparedStatement
instance on which it
operates are thread safe.
stmt
- The PreparedStatement
to reset. If
null
this method does nothing.protected void closeResultSet(ResultSet rs)
protected void closeStatement(Statement stmt)
protected void logException(String message, SQLException se)
protected void prepareSchemaObjectPrefix() throws Exception
schemaObjectPrefix
does only consist of
characters that are allowed in names on the target database. Illegal
characters will be escaped as necessary.Exception
- if an error occursprotected void checkSchema() throws Exception
Exception
- if an error occursprotected String createSchemaSql(String sql)
sql
- The SQL with embedded wildcards.protected InputStream getSchemaDDL()
protected void buildSQLStatements()
protected void initPreparedStatements() throws SQLException
SQLException
- if an error occursCopyright © 2004–2021 The Apache Software Foundation. All rights reserved.