001/* 002 * Copyright 2002-2012 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.dao; 018 019import org.springframework.core.NestedRuntimeException; 020 021/** 022 * Root of the hierarchy of data access exceptions discussed in 023 * <a href="https://www.amazon.com/exec/obidos/tg/detail/-/0764543857/">Expert One-On-One J2EE Design and Development</a>. 024 * Please see Chapter 9 of this book for detailed discussion of the 025 * motivation for this package. 026 * 027 * <p>This exception hierarchy aims to let user code find and handle the 028 * kind of error encountered without knowing the details of the particular 029 * data access API in use (e.g. JDBC). Thus it is possible to react to an 030 * optimistic locking failure without knowing that JDBC is being used. 031 * 032 * <p>As this class is a runtime exception, there is no need for user code 033 * to catch it or subclasses if any error is to be considered fatal 034 * (the usual case). 035 * 036 * @author Rod Johnson 037 */ 038@SuppressWarnings("serial") 039public abstract class DataAccessException extends NestedRuntimeException { 040 041 /** 042 * Constructor for DataAccessException. 043 * @param msg the detail message 044 */ 045 public DataAccessException(String msg) { 046 super(msg); 047 } 048 049 /** 050 * Constructor for DataAccessException. 051 * @param msg the detail message 052 * @param cause the root cause (usually from using a underlying 053 * data access API such as JDBC) 054 */ 055 public DataAccessException(String msg, Throwable cause) { 056 super(msg, cause); 057 } 058 059}