001/* 002 * Copyright 2002-2019 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * https://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package org.springframework.transaction; 018 019import java.io.Flushable; 020 021/** 022 * Representation of the status of a transaction. 023 * 024 * <p>Transactional code can use this to retrieve status information, 025 * and to programmatically request a rollback (instead of throwing 026 * an exception that causes an implicit rollback). 027 * 028 * <p>Includes the {@link SavepointManager} interface to provide access 029 * to savepoint management facilities. Note that savepoint management 030 * is only available if supported by the underlying transaction manager. 031 * 032 * @author Juergen Hoeller 033 * @since 27.03.2003 034 * @see #setRollbackOnly() 035 * @see PlatformTransactionManager#getTransaction 036 * @see org.springframework.transaction.support.TransactionCallback#doInTransaction 037 * @see org.springframework.transaction.interceptor.TransactionInterceptor#currentTransactionStatus() 038 */ 039public interface TransactionStatus extends TransactionExecution, SavepointManager, Flushable { 040 041 /** 042 * Return whether this transaction internally carries a savepoint, 043 * that is, has been created as nested transaction based on a savepoint. 044 * <p>This method is mainly here for diagnostic purposes, alongside 045 * {@link #isNewTransaction()}. For programmatic handling of custom 046 * savepoints, use the operations provided by {@link SavepointManager}. 047 * @see #isNewTransaction() 048 * @see #createSavepoint() 049 * @see #rollbackToSavepoint(Object) 050 * @see #releaseSavepoint(Object) 051 */ 052 boolean hasSavepoint(); 053 054 /** 055 * Flush the underlying session to the datastore, if applicable: 056 * for example, all affected Hibernate/JPA sessions. 057 * <p>This is effectively just a hint and may be a no-op if the underlying 058 * transaction manager does not have a flush concept. A flush signal may 059 * get applied to the primary resource or to transaction synchronizations, 060 * depending on the underlying resource. 061 */ 062 @Override 063 void flush(); 064 065}