|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2008 the original author or authors. |
| 2 | + * Copyright 2002-2009 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
@@ -625,16 +625,21 @@ public static DataAccessException convertHibernateAccessException(HibernateExcep
|
625 | 625 | return new DataAccessResourceFailureException(ex.getMessage(), ex);
|
626 | 626 | }
|
627 | 627 | if (ex instanceof SQLGrammarException) {
|
628 |
| - return new InvalidDataAccessResourceUsageException(ex.getMessage(), ex); |
| 628 | + SQLGrammarException jdbcEx = (SQLGrammarException) ex; |
| 629 | + return new InvalidDataAccessResourceUsageException(ex.getMessage() + "; SQL [" + jdbcEx.getSQL() + "]", ex); |
629 | 630 | }
|
630 | 631 | if (ex instanceof LockAcquisitionException) {
|
631 |
| - return new CannotAcquireLockException(ex.getMessage(), ex); |
| 632 | + LockAcquisitionException jdbcEx = (LockAcquisitionException) ex; |
| 633 | + return new CannotAcquireLockException(ex.getMessage() + "; SQL [" + jdbcEx.getSQL() + "]", ex); |
632 | 634 | }
|
633 | 635 | if (ex instanceof ConstraintViolationException) {
|
634 |
| - return new DataIntegrityViolationException(ex.getMessage(), ex); |
| 636 | + ConstraintViolationException jdbcEx = (ConstraintViolationException) ex; |
| 637 | + return new DataIntegrityViolationException(ex.getMessage() + "; SQL [" + jdbcEx.getSQL() + |
| 638 | + "]; constraint [" + jdbcEx.getConstraintName() + "]", ex); |
635 | 639 | }
|
636 | 640 | if (ex instanceof DataException) {
|
637 |
| - return new DataIntegrityViolationException(ex.getMessage(), ex); |
| 641 | + DataException jdbcEx = (DataException) ex; |
| 642 | + return new DataIntegrityViolationException(ex.getMessage() + "; SQL [" + jdbcEx.getSQL() + "]", ex); |
638 | 643 | }
|
639 | 644 | if (ex instanceof JDBCException) {
|
640 | 645 | return new HibernateJdbcException((JDBCException) ex);
|
|
0 commit comments