001/*
002 * Copyright 2002-2013 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.support;
018
019import java.io.Flushable;
020
021/**
022 * Interface to be implemented by transaction objects that are able to
023 * return an internal rollback-only marker, typically from a another
024 * transaction that has participated and marked it as rollback-only.
025 *
026 * <p>Autodetected by DefaultTransactionStatus, to always return a
027 * current rollbackOnly flag even if not resulting from the current
028 * TransactionStatus.
029 *
030 * @author Juergen Hoeller
031 * @since 1.1
032 * @see DefaultTransactionStatus#isRollbackOnly
033 */
034public interface SmartTransactionObject extends Flushable {
035
036        /**
037         * Return whether the transaction is internally marked as rollback-only.
038         * Can, for example, check the JTA UserTransaction.
039         * @see javax.transaction.UserTransaction#getStatus
040         * @see javax.transaction.Status#STATUS_MARKED_ROLLBACK
041         */
042        boolean isRollbackOnly();
043
044        /**
045         * Flush the underlying sessions to the datastore, if applicable:
046         * for example, all affected Hibernate/JPA sessions.
047         */
048        @Override
049        void flush();
050
051}