]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-2234 JpaDatabaseSession: improve exception message for persist operations
authorEvgeny Mandrikov <mandrikov@gmail.com>
Thu, 7 Apr 2011 13:14:17 +0000 (17:14 +0400)
committerEvgeny Mandrikov <mandrikov@gmail.com>
Thu, 7 Apr 2011 13:35:48 +0000 (17:35 +0400)
sonar-core/src/main/java/org/sonar/jpa/session/JpaDatabaseSession.java

index 6c87056f278598db581e4931fcfb2e59359001d4..12c0f7c7a88ff3297503d28ed250ee7ed69c4691 100644 (file)
@@ -109,7 +109,15 @@ public class JpaDatabaseSession extends DatabaseSession {
   }
 
   private void internalSave(Object model, boolean flushIfNeeded) {
-    entityManager.persist(model);
+    try {
+      entityManager.persist(model);
+    } catch (PersistenceException e) {
+      /*
+       * See http://jira.codehaus.org/browse/SONAR-2234
+       * In some cases Hibernate can throw exceptions without meaningful information about context, so we improve them here.
+       */
+      throw new PersistenceException("Unable to persist : " + model, e);
+    }
     if (flushIfNeeded && (++index % BATCH_SIZE == 0)) {
       commit();
     }