<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head> 
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0"> 
        <base href="https://hibernate.atlassian.net"> 
        <title>Message Title</title> 
    </head> 
    <body class="jira" style="color: #333333; font-family: Arial, sans-serif; font-size: 14px; line-height: 1.429"> 
        <table id="background-table" cellpadding="0" cellspacing="0" width="100%" style="border-collapse: collapse; mso-table-lspace: 0; mso-table-rspace: 0; background-color: #f5f5f5; border-collapse: collapse; mso-table-lspace: 0; mso-table-rspace: 0" bgcolor="#f5f5f5"> 
            <!-- header here --> 
            <tbody>
                <tr> 
                    <td id="header-pattern-container" style="padding: 0; border-collapse: collapse; padding: 10px 20px"> 
                        <table id="header-pattern" cellspacing="0" cellpadding="0" border="0" style="border-collapse: collapse; mso-table-lspace: 0; mso-table-rspace: 0"> 
                            <tbody>
                                <tr> 
                                    <td id="header-avatar-image-container" valign="top" style="padding: 0; border-collapse: collapse; vertical-align: top; width: 32px; padding-right: 8px" width="32"> <img id="header-avatar-image" class="image_fix" src="https://avatar-cdn.atlassian.com/c32c4103dacf291cdfa0439e34f2c07e?s=48&amp;d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2Fc32c4103dacf291cdfa0439e34f2c07e%3Fd%3Dmm%26s%3D48%26noRedirect%3Dtrue" height="32" width="32" border="0" style="border-radius: 3px; vertical-align: top"> </td> 
                                    <td id="header-text-container" valign="middle" style="padding: 0; border-collapse: collapse; vertical-align: middle; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; mso-line-height-rule: exactly; mso-text-raise: 1px"> <a class="user-hover" rel="gbadner" id="email_gbadner" href="https://hibernate.atlassian.net/secure/ViewProfile.jspa?name=gbadner" style="color:#6c797f;; color: #3b73af; text-decoration: none">Gail Badner</a> <strong>updated</strong> an issue </td> 
                                </tr> 
                            </tbody>
                        </table> </td> 
                </tr> 
                <tr> 
                    <td id="email-content-container" style="padding: 0; border-collapse: collapse; padding: 0 20px"> 
                        <table id="email-content-table" cellspacing="0" cellpadding="0" border="0" width="100%" style="border-collapse: collapse; mso-table-lspace: 0; mso-table-rspace: 0; border-spacing: 0; border-collapse: separate"> 
                            <tbody>
                                <tr> 
                                    <!-- there needs to be content in the cell for it to render in some clients --> 
                                    <td class="email-content-rounded-top mobile-expand" style="padding: 0; border-collapse: collapse; color: #ffffff; padding: 0 15px 0 16px; height: 15px; background-color: #ffffff; border-left: 1px solid #cccccc; border-top: 1px solid #cccccc; border-right: 1px solid #cccccc; border-bottom: 0; border-top-right-radius: 5px; border-top-left-radius: 5px; height: 10px; line-height: 10px; padding: 0 15px 0 16px; mso-line-height-rule: exactly" height="10" bgcolor="#ffffff">&nbsp;</td> 
                                </tr> 
                                <tr> 
                                    <td class="email-content-main mobile-expand " style="padding: 0; border-collapse: collapse; border-left: 1px solid #cccccc; border-right: 1px solid #cccccc; border-top: 0; border-bottom: 0; padding: 0 15px 0 16px; background-color: #ffffff" bgcolor="#ffffff"> 
                                        <table class="page-title-pattern" cellspacing="0" cellpadding="0" border="0" width="100%" style="border-collapse: collapse; mso-table-lspace: 0; mso-table-rspace: 0"> 
                                            <tbody>
                                                <tr> 
                                                    <td class="page-title-pattern-first-line " style="padding: 0; border-collapse: collapse; font-family: Arial, sans-serif; font-size: 14px; padding-top: 10px"> <a href="https://hibernate.atlassian.net/browse/HHH" style="color: #3b73af; text-decoration: none">Hibernate ORM</a> / <a href="https://hibernate.atlassian.net/browse/HHH-12666" style="color: #3b73af; text-decoration: none"><img src="cid:jira-generated-image-avatar-be984549-dd39-4155-9b55-fcb8501f03a7" height="16" width="16" border="0" align="absmiddle" alt="Bug" style="vertical-align: text-bottom"></a> <a href="https://hibernate.atlassian.net/browse/HHH-12666" style="color: #3b73af; text-decoration: none">HHH-12666</a> </td> 
                                                </tr> 
                                                <tr> 
                                                    <td style="vertical-align: top;; padding: 0; border-collapse: collapse; padding-right: 5px; font-size: 20px; line-height: 30px; mso-line-height-rule: exactly" class="page-title-pattern-header-container"> <span class="page-title-pattern-header" style="font-family: Arial, sans-serif; padding: 0; font-size: 20px; line-height: 30px; mso-text-raise: 2px; mso-line-height-rule: exactly; vertical-align: middle"> <a href="https://hibernate.atlassian.net/browse/HHH-12666" style="color: #3b73af; text-decoration: none">Add an option for restoring 5.1 native exception handling </a> </span> </td> 
                                                </tr> 
                                            </tbody>
                                        </table> </td> 
                                </tr> 
                                <tr> 
                                    <td class="email-content-main mobile-expand  wrapper-special-margin" style="padding: 0; border-collapse: collapse; border-left: 1px solid #cccccc; border-right: 1px solid #cccccc; border-top: 0; border-bottom: 0; padding: 0 15px 0 16px; background-color: #ffffff; padding-top: 10px; padding-bottom: 5px" bgcolor="#ffffff"> 
                                        <table class="keyvalue-table" style="border-collapse: collapse; mso-table-lspace: 0; mso-table-rspace: 0"> 
                                            <tbody>
                                                <tr> 
                                                    <th style="color: #707070; font: normal 14px/20px Arial, sans-serif; text-align: left; vertical-align: top; padding: 2px 0">Change By:</th> 
                                                    <td style="padding: 0; border-collapse: collapse; font: normal 14px/20px Arial, sans-serif; padding: 2px 0 2px 5px; vertical-align: top"> <a class="user-hover" rel="gbadner" id="email_gbadner" href="https://hibernate.atlassian.net/secure/ViewProfile.jspa?name=gbadner" style="color:#6c797f;; color: #3b73af; text-decoration: none">Gail Badner</a> </td> 
                                                </tr> 
                                            </tbody>
                                        </table> </td> 
                                </tr> 
                                <tr> 
                                    <td class="email-content-main mobile-expand  issue-description-container" style="padding: 0; border-collapse: collapse; border-left: 1px solid #cccccc; border-right: 1px solid #cccccc; border-top: 0; border-bottom: 0; padding: 0 15px 0 16px; background-color: #ffffff; padding-top: 5px; padding-bottom: 10px" bgcolor="#ffffff"> 
                                        <table class="text-paragraph-pattern" cellspacing="0" cellpadding="0" border="0" width="100%" style="border-collapse: collapse; mso-table-lspace: 0; mso-table-rspace: 0; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; mso-line-height-rule: exactly; mso-text-raise: 2px"> 
                                            <tbody>
                                                <tr> 
                                                    <td class="text-paragraph-pattern-container mobile-resize-text " style="padding: 0; border-collapse: collapse; padding: 0 0 10px"> <span class="diffcontext">Exception handling changed in 5.2 when hibernate-entitymanager was merged into hibernate-core. This change is documented in the 5.2 migration guide. [1]<br><br>Here is the relevant text:<br><br>"org.hibernate.HibernateException now extends javax.persistence.PersistenceExceptions. Hibernate methods that "override" methods from their JPA counterparts now will also throw various JDK defined RuntimeExceptions (such as IllegalArgumentException, IllegalStateException, etc) as required by the JPA contract."<br><br>While digging into this, I see that a HibernateException thrown when using 5.1 may, in 5.3, be unwrapped, or may be wrapped by a PersistenceException (or a subclass), IllegalArgumentException, or IllegalStateException, depending on the particular operation being performed when the HibernateException is thrown. <br><br>The reason why the exceptions may be wrapped or unwrapped is because Hibernate converts exceptions&nbsp;&nbsp;(via AbstractSharedSessionContract#exceptionConverter) for JPA operations which may wrap the HibernateException or throw a different exception. Hibernate does not convert exceptions from strictly "native" operations, so those exceptions remain unwrapped. <br><br>Here are a couple of examples to illustrate:<br><br>1) A HibernateException (org.hibernate.TransientObjectException) was thrown in 5.1. In 5.3, the same condition can result in&nbsp;&nbsp;org.hibernate.TransientObjectException that is either unwrapped, or wrapped by IllegalStateException. I've pushed a test to my fork to illustrate. [2] <br><br>Thrown during Session#save, #saveOrUpdate<br>In 5.1: org.hibernate.TransientObjectException (unwrapped)<br>In 5.3: org.hibernate.TransientObjectException (unwrapped)<br><br>Thrown during Session#persist, #merge, #flush<br>In 5.1, org.hibernate.TransientObjectException (unwrapped)<br>In 5.3, org.hibernate.TransientObjectException wrapped by IllegalStateException<br><br>2) A HibernateException thrown when using 5.1 may be wrapped by a PersistenceException, even though HibernateException already extends PersistenceException.<br><br>For example, see TransactionTimeoutTest#testTransactionTimeoutFailure:<br>https://github.com/hibernate/hibernate-orm/blob/master/hibernate-core/src/test/java/org/hibernate/test/tm/TransactionTimeoutTest.java#L60-L82<br><br>The exception thrown by the test indicates that the transaction timed out. This exception is important enough that an application might retry the operation, or at least log for future investigation.<br><br>Thrown during Session#persist (or when changed to use Session#merge or Session#flush):<br>In 5.1: org.hibernate.TransactionException (unwrapped)<br>In 5.3: org.hibernate.TransactionException wrapped by javax.persistence.PersistenceException<br><br>Thrown if the test is changed to use Session#save or #saveOrUpdate instead:<br>In 5.1: org.hibernate.TransactionException (unwrapped)<br>In 5.3: org.hibernate.TransactionException (unwrapped)<br><br>Similarly, by adding some logging, I see that HibernateException objects can be wrapped by PersistenceException when running the 5.3 hibernate-core unit tests. Depending on the context, I see that some of the following exceptions can be wrapped or unwrapped.<br><br>org.hibernate.exception.ConstraintViolationException<br>org.hibernate.exception.DataException<br>org.hibernate.exception.GenericJDBCException<br>org.hibernate.exception.SQLGrammarException<br>org.hibernate.id.IdentifierGenerationException<br>org.hibernate.loader.custom.NonUniqueDiscoveredSqlAliasException<br>org.hibernate.PersistentObjectException<br>org.hibernate.PropertyAccessException<br>org.hibernate.PropertyValueException<br>org.hibernate.TransactionException<br><br>You can see an example using org.hibernate.exception.ConstraintViolationException at [3].<br><br>In order to deal with these differences, an application could change the following (which was appropriate for 5.1):<br><br>try {<br>&nbsp;&nbsp;&nbsp;&nbsp;...<br>}<br>catch (HibernateException ex) {<br>&nbsp;&nbsp;&nbsp;&nbsp;procressHibernateException( ex );<br>}<br><br>to the following for 5.3:<br><br>try {<br>&nbsp;&nbsp;&nbsp;&nbsp;...<br>}<br>catch (PersistenceException | IllegalStateException | IllegalArgumentException ex) {<br>&nbsp;&nbsp;&nbsp;&nbsp;if ( HibernateException.class.isInstance( ex ) ) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;handleHibernateException( (HibernateException) ex );<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;else if ( HibernateException.class.isInstance( ex.getCause() ) ) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;handleHibernateException( (HibernateException) ex.getCause() );<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br>}<br><br>IMO, it's a little clumsy having to deal with both wrapped and unwrapped exceptions. It would be better if exceptions were consistently wrapped, or consistently unwrapped.<br><br>To deal with this,</span> <span class="diffaddedchars" style="background-color:#ddfade;"> {{</span> <span class="diffcontext"> hibernate.</span> <span class="diffremovedchars" style="background-color: #ffe7e7; text-decoration:line-through;">exception_converter could</span> <span class="diffaddedchars" style="background-color:#ddfade;">native_exception_handling_51_compliance}} will</span> <span class="diffcontext"> be added with</span> <span class="diffremovedchars" style="background-color: #ffe7e7; text-decoration:line-through;"> the following</span> <span class="diffaddedchars" style="background-color:#ddfade;"> possible</span> <span class="diffcontext"> values</span> <span class="diffremovedchars" style="background-color: #ffe7e7; text-decoration:line-through;">:<br><br>jpa - default for JPA applications</span> <span class="diffaddedchars" style="background-color:#ddfade;"> {{true}} or {{false}}</span> <span class="diffcontext"> (</span> <span class="diffremovedchars" style="background-color: #ffe7e7; text-decoration:line-through;">org.hibernate.internal.ExceptionConverterImpl)<br>native -</span> <span class="diffcontext"> default</span> <span class="diffremovedchars" style="background-color: #ffe7e7; text-decoration:line-through;"> for native applications&nbsp;&nbsp;that does not wrap HibernateException<br><br>Should there actually be 2 "native" implementations: <br>1</span> <span class="diffcontext">)</span> <span class="diffremovedchars" style="background-color: #ffe7e7; text-decoration:line-through;"> native-5</span> <span class="diffcontext">.</span> <span class="diffremovedchars" style="background-color: #ffe7e7; text-decoration:line-through;">2</span> <span class="diffaddedchars" style="background-color:#ddfade;"><br><br>When set to {{true}}</span> <span class="diffcontext">,</span> <span class="diffremovedchars" style="background-color: #ffe7e7; text-decoration:line-through;"> conform</span> <span class="diffaddedchars" style="background-color:#ddfade;"> {{HibernateException}} will not be wrapped or converted according</span> <span class="diffcontext"> to</span> <span class="diffremovedchars" style="background-color: #ffe7e7; text-decoration:line-through;"> 5</span> <span class="diffaddedchars" style="background-color:#ddfade;"> the JPA specification</span> <span class="diffcontext">.</span> <span class="diffremovedchars" style="background-color: #ffe7e7; text-decoration:line-through;">2 exceptions (wrapped and unwrapped);</span> <span class="diffcontext"><br></span> <span class="diffremovedchars" style="background-color: #ffe7e7; text-decoration:line-through;">2) native-5</span> <span class="diffaddedchars" style="background-color:#ddfade;"><br>This setting will be ignored for a SessionFactory built via JPA bootstrapping</span> <span class="diffcontext">.</span> <span class="diffremovedchars" style="background-color: #ffe7e7; text-decoration:line-through;">1, conform to 5.1 exceptions (unwrapped)?</span> <span class="diffcontext"><br><br>[1] https://github.com/hibernate/hibernate-orm/blob/5.2/migration-guide.adoc<br>[2] https://github.com/gbadner/hibernate-core/blob/exception-compatibility/orm/hibernate-orm-5/src/test/java/org/hibernate/bugs/ORMTransientObjectExceptionUnitTestCase.java<br>[3] https://github.com/gbadner/hibernate-core/blob/exception-compatibility/orm/hibernate-orm-5/src/test/java/org/hibernate/bugs/ORMConstraintViolationExceptionUnitTestCase.java</span> </td> 
                                                </tr> 
                                            </tbody>
                                        </table> </td> 
                                </tr> 
                                <tr> 
                                    <td class="email-content-main mobile-expand " style="padding: 0; border-collapse: collapse; border-left: 1px solid #cccccc; border-right: 1px solid #cccccc; border-top: 0; border-bottom: 0; padding: 0 15px 0 16px; background-color: #ffffff" bgcolor="#ffffff"> <script type="application/ld+json">
{
  "@context": "http://schema.org",
  "@type": "EmailMessage",
  "description": "View Issue",
  "potentialAction": {
    "@type": "ViewAction",
        "target": "https://hibernate.atlassian.net/browse/HHH-12666?inbox=true&",
    "name": "View Issue"
      },
  "publisher": {
    "@type": "Organization",
    "name": "Atlassian",
    "url": "https://www.atlassian.com"
  }
}
</script> 
                                        <table id="actions-pattern" cellspacing="0" cellpadding="0" border="0" width="100%" style="border-collapse: collapse; mso-table-lspace: 0; mso-table-rspace: 0; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; mso-line-height-rule: exactly; mso-text-raise: 1px"> 
                                            <tbody>
                                                <tr> 
                                                    <td id="actions-pattern-container" valign="middle" style="padding: 0; border-collapse: collapse; padding: 10px 0 10px 24px; vertical-align: middle; padding-left: 0"> 
                                                        <table align="left" style="border-collapse: collapse; mso-table-lspace: 0; mso-table-rspace: 0"> 
                                                            <tbody>
                                                                <tr> 
                                                                    <td class="actions-pattern-action-icon-container" style="padding: 0; border-collapse: collapse; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; mso-line-height-rule: exactly; mso-text-raise: 0; vertical-align: middle"> <a href="https://hibernate.atlassian.net/browse/HHH-12666#add-comment" target="_blank" title="Add Comment" style="color: #3b73af; text-decoration: none"> <img class="actions-pattern-action-icon-image" src="cid:jira-generated-image-static-comment-icon-521c3f66-aef7-4885-98f2-a43deacce7ec" alt="Add Comment" title="Add Comment" height="16" width="16" border="0" style="vertical-align: middle"> </a> </td> 
                                                                    <td class="actions-pattern-action-text-container" style="padding: 0; border-collapse: collapse; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; mso-line-height-rule: exactly; mso-text-raise: 4px; padding-left: 5px"> <a href="https://hibernate.atlassian.net/browse/HHH-12666#add-comment" target="_blank" title="Add Comment" style="color: #3b73af; text-decoration: none">Add Comment</a> </td> 
                                                                </tr> 
                                                            </tbody>
                                                        </table> </td> 
                                                </tr> 
                                            </tbody>
                                        </table> </td> 
                                </tr> 
                                <!-- there needs to be content in the cell for it to render in some clients --> 
                                <tr> 
                                    <td class="email-content-rounded-bottom mobile-expand" style="padding: 0; border-collapse: collapse; color: #ffffff; padding: 0 15px 0 16px; height: 5px; line-height: 5px; background-color: #ffffff; border-top: 0; border-left: 1px solid #cccccc; border-bottom: 1px solid #cccccc; border-right: 1px solid #cccccc; border-bottom-right-radius: 5px; border-bottom-left-radius: 5px; mso-line-height-rule: exactly" height="5" bgcolor="#ffffff">&nbsp;</td> 
                                </tr> 
                            </tbody>
                        </table> </td> 
                </tr> 
                <tr> 
                    <td id="footer-pattern" style="padding: 0; border-collapse: collapse; padding: 12px 20px"> 
                        <table id="footer-pattern-container" cellspacing="0" cellpadding="0" border="0" style="border-collapse: collapse; mso-table-lspace: 0; mso-table-rspace: 0"> 
                            <tbody>
                                <tr> 
                                    <td id="footer-pattern-mobile-separated-links" class="mobile-resize-text" width="100%" colspan="2" style="padding: 0; border-collapse: collapse; color: #999999; font-size: 12px; line-height: 18px; font-family: Arial, sans-serif; mso-line-height-rule: exactly; mso-text-raise: 2px"> Get Jira notifications on your phone! Download the Jira Cloud app for <a href="https://play.google.com/store/apps/details?id=com.atlassian.android.jira.core&amp;referrer=utm_source%3DNotificationLink%26utm_medium%3DEmail" style="color: #3b73af; text-decoration: none">Android</a> or <a href="https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&amp;ct=EmailNotificationLink&amp;mt=8" style="color: #3b73af; text-decoration: none">iOS</a> 
                                        <hr> </td> 
                                </tr> 
                                <tr> 
                                    <td id="footer-pattern-text" class="mobile-resize-text" width="100%" style="padding: 0; border-collapse: collapse; color: #999999; font-size: 12px; line-height: 18px; font-family: Arial, sans-serif; mso-line-height-rule: exactly; mso-text-raise: 2px"> This message was sent by Atlassian Jira <span id="footer-build-information">(v1001.0.0-SNAPSHOT#100090-<span title="800327869ca6231799f89efdcc9a209b6c7439ab" data-commit-id="800327869ca6231799f89efdcc9a209b6c7439ab}">sha1:8003278</span>)</span> </td> 
                                    <td id="footer-pattern-logo-desktop-container" valign="top" style="padding: 0; border-collapse: collapse; padding-left: 20px; vertical-align: top"> 
                                        <table style="border-collapse: collapse; mso-table-lspace: 0; mso-table-rspace: 0"> 
                                            <tbody>
                                                <tr> 
                                                    <td id="footer-pattern-logo-desktop-padding" style="padding: 0; border-collapse: collapse; padding-top: 3px; opacity: 0.150"> <img id="footer-pattern-logo-desktop" src="cid:jira-generated-image-static-footer-desktop-logo-6730f885-7d73-4533-b823-11090a945a0f" alt="Atlassian logo" title="Atlassian logo" width="192" height="24" class="image_fix"> </td> 
                                                </tr> 
                                            </tbody>
                                        </table> </td> 
                                </tr> 
                            </tbody>
                        </table> </td> 
                </tr> 
            </tbody>
        </table>   
    </body>
</html>