Class BaseTransaction

    • Constructor Detail

      • BaseTransaction

        protected BaseTransaction​(TransactionDescriptor descriptor)
        Creates new inactive transaction.
    • Method Detail

      • bindThreadTransaction

        public static void bindThreadTransaction​(Transaction transaction)
        Binds a Transaction to the current thread.
      • getThreadTransaction

        public static Transaction getThreadTransaction()
        Returns a Transaction associated with the current thread, or null if there is no such Transaction.
      • begin

        public void begin()
        Starts a Transaction. If Transaction is not started explicitly, it will be started when the first connection is added.
        Specified by:
        begin in interface Transaction
      • processCommit

        protected abstract void processCommit()
      • processRollback

        protected abstract void processRollback()
      • getConnections

        public Map<String,​Connection> getConnections()
        Description copied from interface: Transaction
        Returns all connections associated with the transaction.
        Specified by:
        getConnections in interface Transaction
        Returns:
        connections associated with the transaction.
      • getOrCreateConnection

        public Connection getOrCreateConnection​(String connectionName,
                                                DataSource dataSource)
                                         throws SQLException
        Description copied from interface: Transaction
        Retrieves a connection for the given symbolic name. If it does not exists, creates a new connection using provided DataSource, and registers it internally.
        Specified by:
        getOrCreateConnection in interface Transaction
        Parameters:
        connectionName - a symbolic name of the connection. Cayenne DataNodes generate a name in the form of "DataNode.Connection.nodename".
        dataSource - DataSource that provides new connections.
        Returns:
        a connection that participates in the current transaction.
        Throws:
        SQLException
      • getExistingConnection

        protected Connection getExistingConnection​(String name)
      • connectionAdded

        protected void connectionAdded​(Connection connection)
      • close

        protected void close()
        Closes all connections associated with transaction.