<!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/efd10107c4ef505f9b764a7a82381d79?s=48&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2Fefd10107c4ef505f9b764a7a82381d79%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="koh" id="email_koh" href="https://hibernate.atlassian.net/secure/ViewProfile.jspa?name=koh" style="color:#6c797f;; color: #3b73af; text-decoration: none">Karsten Ohme</a> <strong>commented</strong> on <a href="https://hibernate.atlassian.net/browse/HHH-10589" style="color: #3b73af; text-decoration: none"><img src="cid:jira-generated-image-avatar-e427acb4-99e3-49e0-b7cc-ef6c83b8f944" height="16" width="16" border="0" align="absmiddle" alt="Bug"> HHH-10589</a> </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"> </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 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-10589" style="color: #3b73af; text-decoration: none">Re: Blobs are duplicated with LobMergeStrategy NEW_LOCATOR_LOB_MERGE_STRATEGY in Dialect</a> </span> </td>
</tr>
</tbody>
</table> </td>
</tr>
<tr>
<td id="text-paragraph-pattern-top" class="email-content-main mobile-expand comment-top-pattern" 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; border-bottom: none; padding-bottom: 0" 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"> <p style="margin: 10px 0 0; margin-top: 0">In the meanwhile until my fix is not applied, here is my version of a path for PostgreSQL 94. The class must be passed with the Hibernate property <em>hibernate.dialect</em>. <br> Note: Instead of extending PostgreSQL94Dialect the real patch would directly apply the above mentioned lines</p> <p style="margin: 10px 0 0">{{<br> {{<br> if ( original == null && target == null )</p> { return null; } <p style="margin: 10px 0 0">if ( original == target)</p> { return original; } <p style="margin: 10px 0 0">}}</p> <p style="margin: 10px 0 0">directly to the Dialect class of Hibernate.</p> <p style="margin: 10px 0 0">{{package your.package;</p> <p style="margin: 10px 0 0">import org.hibernate.dialect.LobMergeStrategy;<br> import org.hibernate.dialect.PostgreSQL94Dialect;<br> import org.hibernate.engine.jdbc.LobCreator;<br> import org.hibernate.engine.jdbc.spi.JdbcServices;<br> import org.hibernate.engine.spi.SessionImplementor;</p> <p style="margin: 10px 0 0">import java.sql.Blob;<br> import java.sql.Clob;<br> import java.sql.NClob;<br> import java.sql.SQLException;</p> <p style="margin: 10px 0 0">/**</p>
<ul>
<li>Sets a LobMergeStrategy not to merge Blobs if they are the same. Old implementation is coming from {@link org.hibernate.dialect.Dialect#NEW_LOCATOR_LOB_MERGE_STRATEGY} <p style="margin: 10px 0 0; margin-top: 0"> is duplicating</p></li>
<li>also the blob which leads to a fast growing database because also if the binary data is not changed it will be duplicated.<br> */<br> public class FixedPostgreSQL94Dialect extends PostgreSQL94Dialect {</li>
</ul> <p style="margin: 10px 0 0"> /**</p>
<ul>
<li>Merge strategy based on creating a new LOB locator.</li>
<li><p></li>
<li>This one returns the original and not a copy if the original and target Blobs are identical.</li>
<li></p><br> */<br> protected static final LobMergeStrategy FIXED_NEW_LOCATOR_LOB_MERGE_STRATEGY = new LobMergeStrategy() {<br> @Override<br> public Blob mergeBlob(Blob original, Blob target, SessionImplementor session)
<div class="error">
<span class="error">Unknown macro: { if (original == null && target == null) { return null; }<br> if (original == target) { return original; }<br> if (original == null) { return null; } if (target == null) { return NEW_LOCATOR_LOB_MERGE_STRATEGY.mergeBlob(original, target, session); } // forward to streaming implementation return STREAM_XFER_LOB_MERGE_STRATEGY.mergeBlob(original, target, session); }</span>
</div></li>
</ul> <p style="margin: 10px 0 0"> @Override<br> public Clob mergeClob(Clob original, Clob target, SessionImplementor session) {<br> if (original == null && target == null) </p> { return null; }<br> if (original == target) { return original; }<br> try { final LobCreator lobCreator = session.getFactory().getServiceRegistry().getService(JdbcServices.class).getLobCreator(session); return original == null ? lobCreator.createClob("") : lobCreator.createClob(original.getCharacterStream(), original.length()); } catch (SQLException e) { throw session.getFactory().getServiceRegistry().getService(JdbcServices.class).getSqlExceptionHelper().convert(e, "unable to merge CLOB data"); }<br> }<br> <br> @Override<br> public NClob mergeNClob(NClob original, NClob target, SessionImplementor session) {<br> if (original == null && target == null) { return null; } <p style="margin: 10px 0 0"> if (original == target) </p> { return original; } <p style="margin: 10px 0 0"> try </p> { final LobCreator lobCreator = session.getFactory().getServiceRegistry().getService(JdbcServices.class).getLobCreator(session); return original == null ? lobCreator.createNClob("") : lobCreator.createNClob(original.getCharacterStream(), original.length()); } <p style="margin: 10px 0 0"> catch (SQLException e) </p> { throw session.getFactory().getServiceRegistry().getService(JdbcServices.class).getSqlExceptionHelper().convert(e, "unable to merge NCLOB data"); } <p style="margin: 10px 0 0"> }<br> };</p> <p style="margin: 10px 0 0"> public LobMergeStrategy getLobMergeStrategy() </p> { return FIXED_NEW_LOCATOR_LOB_MERGE_STRATEGY; } <p style="margin: 10px 0 0">}<br> }}</p> </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-10589?inbox=true&focusedCommentId=101673&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-101673",
"name": "View Comment"
},
"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-10589#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-ae537acb-8dfe-4fcc-9457-f318ca55a8ab" 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-10589#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"> </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&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&ct=EmailNotificationLink&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#100082-<span title="d1dd9cd5f846b1427168f25ba3cd23169f819d4c" data-commit-id="d1dd9cd5f846b1427168f25ba3cd23169f819d4c}">sha1:d1dd9cd</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-0b1dee52-e93c-4ece-be9c-8bfd5f5fe93d" 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>
<img src="https://u4043402.ct.sendgrid.net/wf/open?upn=YNXLe5Uzuivj8jGpuXra04BSJ-2BS7raa1puTAtyVUP-2F0UG25sB-2BHToWWBMcbXwnNUbBsqaihZTl7xIVv7JUysp3PaCvIxjom-2FRcYhwJ-2BE4vL9ouuISZfBeMp0DterhLOaOn1m85YChw4sJrq0dJWxkrSGxHdMjMm8ns74VhfkO3-2FgoRNJu78dz-2Bsy7u5ocT-2BGvXYuoXLV4L0zQx3FukFvBeg33t8PBGQ2-2Bh501nOfHrUy5rqbMhqVih8H3n6D8mvuagKiG0ZKtho9evuNEYTqVmTcXnxY9m-2BrXZuXAWJ8j8bsLQNOk9zJaBKrVIQp6gX3T30QNd3oUNpo32Jj5-2BpRzp4ouYlq1WIs6hcF5-2BJrh1GD5jPOzmKhJCC0YCmGsyPsKgzDH6IBifvOnx7tA71-2B61EJ6twsMoWZ8-2B72WFlVdL7j98Nl5XXXmiFeL6Ztv985sxmsK0euX19e35TELclOrQ-3D-3D" alt="" width="1" height="1" border="0" style="height:1px !important;width:1px !important;border-width:0 !important;margin-top:0 !important;margin-bottom:0 !important;margin-right:0 !important;margin-left:0 !important;padding-top:0 !important;padding-bottom:0 !important;padding-right:0 !important;padding-left:0 !important;"/>
</body>
</html>