diff --git a/org.springframework.orm/src/main/java/org/springframework/orm/jpa/EntityManagerFactoryUtils.java b/org.springframework.orm/src/main/java/org/springframework/orm/jpa/EntityManagerFactoryUtils.java index 9196b8dee4f8..02963e2fda02 100644 --- a/org.springframework.orm/src/main/java/org/springframework/orm/jpa/EntityManagerFactoryUtils.java +++ b/org.springframework.orm/src/main/java/org/springframework/orm/jpa/EntityManagerFactoryUtils.java @@ -1,5 +1,5 @@ /* - * 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 static DataAccessException convertJpaAccessExceptionIfPossible(RuntimeExc 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); diff --git a/org.springframework.transaction/src/main/java/org/springframework/dao/EmptyResultDataAccessException.java b/org.springframework.transaction/src/main/java/org/springframework/dao/EmptyResultDataAccessException.java index f10e84e3d985..dfbb86d54bc5 100644 --- a/org.springframework.transaction/src/main/java/org/springframework/dao/EmptyResultDataAccessException.java +++ b/org.springframework.transaction/src/main/java/org/springframework/dao/EmptyResultDataAccessException.java @@ -1,5 +1,5 @@ /* - * 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 EmptyResultDataAccessException(String msg, int expectedSize) { 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); + } + } diff --git a/org.springframework.transaction/src/main/java/org/springframework/dao/IncorrectResultSizeDataAccessException.java b/org.springframework.transaction/src/main/java/org/springframework/dao/IncorrectResultSizeDataAccessException.java index f2af289b972c..98f8379b332a 100644 --- a/org.springframework.transaction/src/main/java/org/springframework/dao/IncorrectResultSizeDataAccessException.java +++ b/org.springframework.transaction/src/main/java/org/springframework/dao/IncorrectResultSizeDataAccessException.java @@ -1,5 +1,5 @@ /* - * 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 IncorrectResultSizeDataAccessException(String msg, int expectedSize) { /** * 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 IncorrectResultSizeDataAccessException(String msg, int expectedSize, int 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; } }