提交 2a0714b4 编写于 作者: J Juergen Hoeller

converted EmptyResultDataAccessException preserves JPA NoResultException as root cause (SPR-9041)

上级 efd2783d
/*
* Copyright 2002-2011 the original author or authors.
* Copyright 2002-2012 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -306,7 +306,7 @@ public abstract class EntityManagerFactoryUtils {
return new JpaObjectRetrievalFailureException((EntityNotFoundException) ex);
}
if (ex instanceof NoResultException) {
return new EmptyResultDataAccessException(ex.getMessage(), 1);
return new EmptyResultDataAccessException(ex.getMessage(), 1, ex);
}
if (ex instanceof NonUniqueResultException) {
return new IncorrectResultSizeDataAccessException(ex.getMessage(), 1, ex);
......
/*
* Copyright 2002-2006 the original author or authors.
* Copyright 2002-2012 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -43,4 +43,14 @@ public class EmptyResultDataAccessException extends IncorrectResultSizeDataAcces
super(msg, expectedSize, 0);
}
/**
* Constructor for EmptyResultDataAccessException.
* @param msg the detail message
* @param expectedSize the expected result size
* @param ex the wrapped exception
*/
public EmptyResultDataAccessException(String msg, int expectedSize, Throwable ex) {
super(msg, expectedSize, 0, ex);
}
}
/*
* Copyright 2002-2006 the original author or authors.
* Copyright 2002-2012 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -68,8 +68,8 @@ public class IncorrectResultSizeDataAccessException extends DataRetrievalFailure
/**
* Constructor for IncorrectResultSizeDataAccessException.
* @param msg the detail message
* @param ex the wrapped exception
* @param expectedSize the expected result size
* @param ex the wrapped exception
*/
public IncorrectResultSizeDataAccessException(String msg, int expectedSize, Throwable ex) {
super(msg, ex);
......@@ -89,19 +89,32 @@ public class IncorrectResultSizeDataAccessException extends DataRetrievalFailure
this.actualSize = actualSize;
}
/**
* Constructor for IncorrectResultSizeDataAccessException.
* @param msg the detail message
* @param expectedSize the expected result size
* @param actualSize the actual result size (or -1 if unknown)
* @param ex the wrapped exception
*/
public IncorrectResultSizeDataAccessException(String msg, int expectedSize, int actualSize, Throwable ex) {
super(msg, ex);
this.expectedSize = expectedSize;
this.actualSize = actualSize;
}
/**
* Return the expected result size.
*/
public int getExpectedSize() {
return expectedSize;
return this.expectedSize;
}
/**
* Return the actual result size (or -1 if unknown).
*/
public int getActualSize() {
return actualSize;
return this.actualSize;
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册