org.neo4j.ogm.transaction.AbstractTransaction Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of neo4j-ogm-api Show documentation
Show all versions of neo4j-ogm-api Show documentation
Neo4j-OGM's internal Api for connecting different transports.
/*
* Copyright (c) 2002-2016 "Neo Technology,"
* Network Engine for Objects in Lund AB [http://neotechnology.com]
*
* This product is licensed to you under the Apache License, Version 2.0 (the "License").
* You may not use this product except in compliance with the License.
*
* This product may include a number of subcomponents with
* separate copyright notices and license terms. Your use of the source
* code for these subcomponents is subject to the terms and
* conditions of the subcomponent's license, as noted in the LICENSE file.
*/
package org.neo4j.ogm.transaction;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicLong;
import org.neo4j.ogm.exception.TransactionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* @author vince
*/
public abstract class AbstractTransaction implements Transaction {
private final Logger logger = LoggerFactory.getLogger(Transaction.class);
protected final TransactionManager transactionManager;
/* Neo4j does not support nested transactions, but it does allow a transaction to be declared in the context of
* another one. These 'placebo' transactions only have an effect if their unit of work is rolled back, in which
* case the entire transaction will be rolled back. In the OGM they are modelled as extensions to the top-level
* transaction, and managed via a simple extension counter. Every new transaction increments the counter, every
* rollback or commit decrements the counter. Rollback/Commit only get executed when the counter = 0, but a
* rollback of an extension will mark the entire transaction to be rolled back, and an attempt to commit such
* a transaction will fail.
*/
protected final AtomicLong extendsCount = new AtomicLong();
/* Objects which are newly persisted into the graph should be registered on the transaction.
* In the event that a rollback occurs, these objects will have been assigned an id from the database
* but will be deleted from the graph, so we can reset their ids to null, in order to allow
* a subsequent save request to operate correctly */
private List