Class DatabasePersistenceManager

    • Field Detail

      • SCHEMA_OBJECT_PREFIX_VARIABLE

        protected static final String SCHEMA_OBJECT_PREFIX_VARIABLE
        Deprecated.
        See Also:
        Constant Field Values
      • initialized

        protected boolean initialized
        Deprecated.
      • schema

        protected String schema
        Deprecated.
      • schemaObjectPrefix

        protected String schemaObjectPrefix
        Deprecated.
      • externalBLOBs

        protected boolean externalBLOBs
        Deprecated.
      • INITIAL_BUFFER_SIZE

        protected static final int INITIAL_BUFFER_SIZE
        Deprecated.
        See Also:
        Constant Field Values
      • autoReconnect

        protected boolean autoReconnect
        Deprecated.
      • SLEEP_BEFORE_RECONNECT

        protected static final int SLEEP_BEFORE_RECONNECT
        Deprecated.
        See Also:
        Constant Field Values
      • nodeStateInsertSQL

        protected String nodeStateInsertSQL
        Deprecated.
      • nodeStateUpdateSQL

        protected String nodeStateUpdateSQL
        Deprecated.
      • nodeStateSelectSQL

        protected String nodeStateSelectSQL
        Deprecated.
      • nodeStateSelectExistSQL

        protected String nodeStateSelectExistSQL
        Deprecated.
      • nodeStateDeleteSQL

        protected String nodeStateDeleteSQL
        Deprecated.
      • propertyStateInsertSQL

        protected String propertyStateInsertSQL
        Deprecated.
      • propertyStateUpdateSQL

        protected String propertyStateUpdateSQL
        Deprecated.
      • propertyStateSelectSQL

        protected String propertyStateSelectSQL
        Deprecated.
      • propertyStateSelectExistSQL

        protected String propertyStateSelectExistSQL
        Deprecated.
      • propertyStateDeleteSQL

        protected String propertyStateDeleteSQL
        Deprecated.
      • nodeReferenceInsertSQL

        protected String nodeReferenceInsertSQL
        Deprecated.
      • nodeReferenceUpdateSQL

        protected String nodeReferenceUpdateSQL
        Deprecated.
      • nodeReferenceSelectSQL

        protected String nodeReferenceSelectSQL
        Deprecated.
      • nodeReferenceSelectExistSQL

        protected String nodeReferenceSelectExistSQL
        Deprecated.
      • nodeReferenceDeleteSQL

        protected String nodeReferenceDeleteSQL
        Deprecated.
      • blobInsertSQL

        protected String blobInsertSQL
        Deprecated.
      • blobUpdateSQL

        protected String blobUpdateSQL
        Deprecated.
      • blobSelectSQL

        protected String blobSelectSQL
        Deprecated.
      • blobSelectExistSQL

        protected String blobSelectExistSQL
        Deprecated.
      • blobDeleteSQL

        protected String blobDeleteSQL
        Deprecated.
      • blobFS

        protected FileSystem blobFS
        Deprecated.
        file system where BLOB data is stored (if externalBLOBs==true)
      • blobStore

        protected BLOBStore blobStore
        Deprecated.
        BLOBStore that manages BLOB data in the file system (if externalBLOBs==true)
    • Constructor Detail

      • DatabasePersistenceManager

        public DatabasePersistenceManager()
        Deprecated.
        Creates a new DatabasePersistenceManager instance.
    • Method Detail

      • getSchemaObjectPrefix

        public String getSchemaObjectPrefix()
        Deprecated.
      • setSchemaObjectPrefix

        public void setSchemaObjectPrefix​(String schemaObjectPrefix)
        Deprecated.
      • getSchema

        public String getSchema()
        Deprecated.
      • setSchema

        public void setSchema​(String schema)
        Deprecated.
      • isExternalBLOBs

        public boolean isExternalBLOBs()
        Deprecated.
      • setExternalBLOBs

        public void setExternalBLOBs​(boolean externalBLOBs)
        Deprecated.
      • setExternalBLOBs

        public void setExternalBLOBs​(String externalBLOBs)
        Deprecated.
      • isSchemaCheckEnabled

        public final boolean isSchemaCheckEnabled()
        Deprecated.
        Returns:
        whether the schema check is enabled
      • setSchemaCheckEnabled

        public final void setSchemaCheckEnabled​(boolean enabled)
        Deprecated.
        Parameters:
        enabled - set whether the schema check is enabled
      • init

        public void init​(PMContext context)
                  throws Exception
        Deprecated.
        Initializes the persistence manager. The persistence manager is permanently bound to the given context, and any required external resources are acquired.

        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.

        Parameters:
        context - persistence manager context
        Throws:
        Exception - if the persistence manager initialization failed
      • close

        public void close()
                   throws Exception
        Deprecated.
        Closes the persistence manager. The consistency of the persistent storage is guaranteed and all acquired resources are released. It is an error to invoke any methods on a closed persistence manager, and implementations are free to enforce this constraint by throwing IllegalStateExceptions in such cases.

        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.

        Throws:
        Exception - if the persistence manager failed to close properly
      • store

        public void store​(ChangeLog changeLog)
                   throws ItemStateException
        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. Properly implemented, this method should ensure that changes are either written completely to the underlying persistence layer, or not at all. Atomically saves the given set of changes.
        Specified by:
        store in interface PersistenceManager
        Overrides:
        store in class AbstractPersistenceManager
        Parameters:
        changeLog - change log containing states that were changed
        Throws:
        ItemStateException - if the changes could not be saved
      • store

        public void store​(NodeState state)
                   throws ItemStateException
        Deprecated.
        Store a node state. Subclass responsibility.

        This method uses shared PreparedStatements 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.

        Specified by:
        store in class AbstractPersistenceManager
        Parameters:
        state - node state to store
        Throws:
        ItemStateException - if an error occurs
      • store

        public void store​(PropertyState state)
                   throws ItemStateException
        Deprecated.
        Store a property state. Subclass responsibility.

        This method uses shared PreparedStatements 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.

        Specified by:
        store in class AbstractPersistenceManager
        Parameters:
        state - property state to store
        Throws:
        ItemStateException - if an error occurs
      • store

        public void store​(NodeReferences refs)
                   throws ItemStateException
        Deprecated.
        Store a references object. Subclass responsibility.

        This method uses shared PreparedStatements 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.

        Specified by:
        store in class AbstractPersistenceManager
        Parameters:
        refs - references object to store
        Throws:
        ItemStateException - if an error occurs
      • exists

        public boolean exists​(NodeId id)
                       throws ItemStateException
        Deprecated.
        Checks whether the identified node exists.
        Parameters:
        id - node id
        Returns:
        true if the node exists, false otherwise
        Throws:
        ItemStateException - on persistence manager errors
      • exists

        public boolean exists​(PropertyId id)
                       throws ItemStateException
        Deprecated.
        Checks whether the identified property exists.
        Parameters:
        id - property id
        Returns:
        true if the property exists, false otherwise
        Throws:
        ItemStateException - on persistence manager errors
      • existsReferencesTo

        public boolean existsReferencesTo​(NodeId targetId)
                                   throws ItemStateException
        Deprecated.
        Checks whether references of the identified target node exist.
        Parameters:
        targetId - target node id
        Returns:
        true if the references exist, false otherwise
        Throws:
        ItemStateException - on persistence manager errors
      • initConnection

        protected void initConnection()
                               throws Exception
        Deprecated.
        Initializes the database connection used by this persistence manager.

        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.

        Throws:
        Exception - if an error occurs
      • getConnection

        protected Connection getConnection()
                                    throws Exception
        Deprecated.
        Abstract factory method for creating a new database connection. This method is called by 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.

        Returns:
        new connection
        Throws:
        Exception - if an error occurs
      • closeConnection

        protected void closeConnection​(Connection connection)
                                throws Exception
        Deprecated.
        Closes the given database connection. This method is called by 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.

        Parameters:
        connection - database connection
        Throws:
        Exception - if an error occurs
      • reestablishConnection

        protected boolean reestablishConnection()
        Deprecated.
        Re-establishes the database connection. This method is called by store(ChangeLog) and executeStmt(String, Object[]) after a SQLException had been encountered.
        Returns:
        true if the connection could be successfully re-established, false otherwise.
      • executeStmt

        protected Statement executeStmt​(String sql,
                                        Object[] params)
                                 throws SQLException
        Deprecated.
        Executes the given SQL statement with the specified parameters. If a SQLException is encountered and autoReconnect==true one attempt is made to re-establish the database connection and re-execute the statement.
        Parameters:
        sql - statement to execute
        params - parameters to set
        Returns:
        the Statement object that had been executed
        Throws:
        SQLException - if an error occurs
      • resetStatement

        protected void resetStatement​(PreparedStatement stmt)
        Deprecated.
        Resets the given 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.

        Parameters:
        stmt - The PreparedStatement to reset. If null this method does nothing.
      • closeResultSet

        protected void closeResultSet​(ResultSet rs)
        Deprecated.
      • closeStatement

        protected void closeStatement​(Statement stmt)
        Deprecated.
      • logException

        protected void logException​(String message,
                                    SQLException se)
        Deprecated.
      • prepareSchemaObjectPrefix

        protected void prepareSchemaObjectPrefix()
                                          throws Exception
        Deprecated.
        Makes sure that schemaObjectPrefix does only consist of characters that are allowed in names on the target database. Illegal characters will be escaped as necessary.
        Throws:
        Exception - if an error occurs
      • checkSchema

        protected void checkSchema()
                            throws Exception
        Deprecated.
        Checks if the required schema objects exist and creates them if they don't exist yet.
        Throws:
        Exception - if an error occurs
      • createSchemaSql

        protected String createSchemaSql​(String sql)
        Deprecated.
        Replace wildcards and return the expanded SQL statement.
        Parameters:
        sql - The SQL with embedded wildcards.
        Returns:
        The SQL with no wildcards present.
      • getSchemaDDL

        protected InputStream getSchemaDDL()
        Deprecated.
        Returns an input stream to the schema DDL resource.
        Returns:
        an input stream to the schema DDL resource.
      • buildSQLStatements

        protected void buildSQLStatements()
        Deprecated.
        Builds the SQL statements
      • initPreparedStatements

        protected void initPreparedStatements()
                                       throws SQLException
        Deprecated.
        Initializes the map of prepared statements.
        Throws:
        SQLException - if an error occurs