Example usage for org.springframework.dao InvalidDataAccessResourceUsageException getRootCause

List of usage examples for org.springframework.dao InvalidDataAccessResourceUsageException getRootCause

Introduction

In this page you can find the example usage for org.springframework.dao InvalidDataAccessResourceUsageException getRootCause.

Prototype

@Nullable
public Throwable getRootCause() 

Source Link

Document

Retrieve the innermost cause of this exception, if any.

Usage

From source file:com.wavemaker.runtime.data.util.DataServiceUtils.java

public static RuntimeException unwrap(Throwable th) {

    th = SystemUtils.getRootException(th);

    if (InvalidDataAccessResourceUsageException.class.isAssignableFrom(th.getClass())) {
        InvalidDataAccessResourceUsageException e = (InvalidDataAccessResourceUsageException) th;
        if (e.getRootCause() != null) {
            th = e.getRootCause();/*from   w w  w.ja  va  2  s .  c om*/
        }
    }
    if (SQLGrammarException.class.isAssignableFrom(th.getClass())) {
        SQLGrammarException s = (SQLGrammarException) th;
        if (s.getSQLException() != null) {
            th = s.getSQLException();
        } else if (s.getCause() != null) {
            th = s.getCause();
        }
    }

    if (th instanceof RuntimeException) {
        return (RuntimeException) th;
    } else {
        return new DataServiceRuntimeException(th);
    }
}