<p dir="ltr">Interesting you don't complain about the same happening from loading by id. As I said above, I think this is the correct behavior. Imo you are looking at it from your specific perspective, which is fine, but here you are asking Hibernate to load something as a particular type which (when it is cached) Hibernate knows it is not. That is the definition of an exception to me.</p>
<br><div class="gmail_quote"><div dir="ltr">On Sun, Dec 17, 2017, 5:55 AM Samuel Andersson (JIRA) <<a href="mailto:jira@hibernate.atlassian.net">jira@hibernate.atlassian.net</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><u></u>
<div class="m_5454292310545400591jira" style="color:#333333;font-family:Arial,sans-serif;font-size:14px;line-height:1.429">
<table id="m_5454292310545400591background-table" cellpadding="0" cellspacing="0" width="100%" style="border-collapse:collapse;background-color:#f5f5f5;border-collapse:collapse" bgcolor="#f5f5f5">
<tbody>
<tr>
<td id="m_5454292310545400591header-pattern-container" style="padding:0;border-collapse:collapse;padding:10px 20px">
<table id="m_5454292310545400591header-pattern" cellspacing="0" cellpadding="0" border="0" style="border-collapse:collapse">
<tbody>
<tr>
<td id="m_5454292310545400591header-avatar-image-container" valign="top" style="padding:0;border-collapse:collapse;vertical-align:top;width:32px;padding-right:8px" width="32"> <img id="m_5454292310545400591header-avatar-image" class="m_5454292310545400591image_fix" src="https://avatar-cdn.atlassian.com/9725b10f1ce85a94dd23e25754bfd080?s=48&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2F9725b10f1ce85a94dd23e25754bfd080%3Fd%3Dmm%26s%3D48%26noRedirect%3Dtrue" height="32" width="32" border="0" style="border-radius:3px;vertical-align:top"> </td>
<td id="m_5454292310545400591header-text-container" valign="middle" style="padding:0;border-collapse:collapse;vertical-align:middle;font-family:Arial,sans-serif;font-size:14px;line-height:20px"> <a class="m_5454292310545400591user-hover" rel="SamuelA" id="m_5454292310545400591email_SamuelA" href="https://hibernate.atlassian.net/secure/ViewProfile.jspa?name=SamuelA" style="color:#6c797f;color:#3b73af;text-decoration:none" target="_blank">Samuel Andersson</a> <strong>commented</strong> on <a href="https://hibernate.atlassian.net/browse/HHH-11532" style="color:#3b73af;text-decoration:none" target="_blank"><img height="16" width="16" border="0" align="absmiddle" alt="Bug"> HHH-11532</a> </td>
</tr>
</tbody>
</table> </td>
</tr>
<tr>
<td id="m_5454292310545400591email-content-container" style="padding:0;border-collapse:collapse;padding:0 20px">
<table id="m_5454292310545400591email-content-table" cellspacing="0" cellpadding="0" border="0" width="100%" style="border-collapse:collapse;border-spacing:0;border-collapse:separate">
<tbody>
<tr>
<td class="m_5454292310545400591email-content-rounded-top m_5454292310545400591mobile-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" height="10" bgcolor="#ffffff"> </td>
</tr>
<tr>
<td class="m_5454292310545400591email-content-main m_5454292310545400591mobile-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="m_5454292310545400591page-title-pattern" cellspacing="0" cellpadding="0" border="0" width="100%" style="border-collapse:collapse">
<tbody>
<tr>
<td style="vertical-align:top;padding:0;border-collapse:collapse;padding-right:5px;font-size:20px;line-height:30px" class="m_5454292310545400591page-title-pattern-header-container"> <span class="m_5454292310545400591page-title-pattern-header" style="font-family:Arial,sans-serif;padding:0;font-size:20px;line-height:30px;vertical-align:middle"> <a href="https://hibernate.atlassian.net/browse/HHH-11532" style="color:#3b73af;text-decoration:none" target="_blank">Re: Loading extended entity by natural ID of base entity that exists in second level cache throws WrongClassException</a> </span> </td>
</tr>
</tbody>
</table> </td>
</tr>
<tr>
<td id="m_5454292310545400591text-paragraph-pattern-top" class="m_5454292310545400591email-content-main m_5454292310545400591mobile-expand m_5454292310545400591comment-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="m_5454292310545400591text-paragraph-pattern" cellspacing="0" cellpadding="0" border="0" width="100%" style="border-collapse:collapse;font-family:Arial,sans-serif;font-size:14px;line-height:20px">
<tbody>
<tr>
<td class="m_5454292310545400591text-paragraph-pattern-container m_5454292310545400591mobile-resize-text" style="padding:0;border-collapse:collapse;padding:0 0 10px"> <p style="margin:10px 0 0;margin-top:0">Are you saying that throwing an exception (sometimes) when cache is enabled and returning null when it's disabled is correct? Should I, as a user of hibernate, have to catch this exception + check for null when I call this method? I don't really care whether an exception is thrown or not, but in my opinion behavior should be consistent regardless of 2nd level cache being enabled or not.</p> </td>
</tr>
</tbody>
</table> </td>
</tr>
<tr>
<td class="m_5454292310545400591email-content-main m_5454292310545400591mobile-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 id="m_5454292310545400591actions-pattern" cellspacing="0" cellpadding="0" border="0" width="100%" style="border-collapse:collapse;font-family:Arial,sans-serif;font-size:14px;line-height:20px">
<tbody>
<tr>
<td id="m_5454292310545400591actions-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">
<tbody>
<tr>
<td class="m_5454292310545400591actions-pattern-action-icon-container" style="padding:0;border-collapse:collapse;font-family:Arial,sans-serif;font-size:14px;line-height:20px;vertical-align:middle"> <a href="https://hibernate.atlassian.net/browse/HHH-11532#add-comment" title="Add Comment" style="color:#3b73af;text-decoration:none" target="_blank"> <img class="m_5454292310545400591actions-pattern-action-icon-image" alt="Add Comment" title="Add Comment" height="16" width="16" border="0" style="vertical-align:middle"> </a> </td>
<td class="m_5454292310545400591actions-pattern-action-text-container" style="padding:0;border-collapse:collapse;font-family:Arial,sans-serif;font-size:14px;line-height:20px;padding-left:5px"> <a href="https://hibernate.atlassian.net/browse/HHH-11532#add-comment" title="Add Comment" style="color:#3b73af;text-decoration:none" target="_blank">Add Comment</a> </td>
</tr>
</tbody>
</table> </td>
</tr>
</tbody>
</table> </td>
</tr>
<tr>
<td class="m_5454292310545400591email-content-rounded-bottom m_5454292310545400591mobile-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" height="5" bgcolor="#ffffff"> </td>
</tr>
</tbody>
</table> </td>
</tr>
<tr>
<td id="m_5454292310545400591footer-pattern" style="padding:0;border-collapse:collapse;padding:12px 20px">
<table id="m_5454292310545400591footer-pattern-container" cellspacing="0" cellpadding="0" border="0" style="border-collapse:collapse">
<tbody>
<tr>
<td id="m_5454292310545400591footer-pattern-mobile-separated-links" class="m_5454292310545400591mobile-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"> 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" target="_blank">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" target="_blank">iOS</a>
<hr> </td>
</tr>
<tr>
<td id="m_5454292310545400591footer-pattern-text" class="m_5454292310545400591mobile-resize-text" width="100%" style="padding:0;border-collapse:collapse;color:#999999;font-size:12px;line-height:18px;font-family:Arial,sans-serif"> This message was sent by Atlassian Jira <span id="m_5454292310545400591footer-build-information">(v1001.0.0-SNAPSHOT#100075-<span title="240e3d8c95c9d4d844814677cc962b000b1bbedf">sha1:240e3d8</span>)</span> </td>
<td id="m_5454292310545400591footer-pattern-logo-desktop-container" valign="top" style="padding:0;border-collapse:collapse;padding-left:20px;vertical-align:top">
<table style="border-collapse:collapse">
<tbody>
<tr>
<td id="m_5454292310545400591footer-pattern-logo-desktop-padding" style="padding:0;border-collapse:collapse;padding-top:3px;opacity:0.150"> <img id="m_5454292310545400591footer-pattern-logo-desktop" alt="Atlassian logo" title="Atlassian logo" width="192" height="24" class="m_5454292310545400591image_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-2BHToWWBMcbXwnNUkiq2oc29-2Buv4OW7iu61jdxcvbo-2FKYpZF3BPuz831Ii0pd6svr3UwXvJuy3idn8KA3gbsqWcY8ApyIxSRTQ6GwILFITUo-2B3IdhyApsvbNHPNK7x7zUrnrNO4P6EVLEesu7mVvNdmGsNlhgzSzUnE4tDO8YJmUFEM5BqRyDJnQm-2B8CnISeG-2FPf8WJk24EiQG44pWKEu3hWPscsj-2BtMWRyn2pd8CYNPkEV2a3QlgrBtRGakwNE-2Fz1jYcWy-2BCU5RKNUENntyXagDuoy1APo7RuXRSBd-2Fw-2FUuMRd58SnmognM1-2FyUj9doTC3UWpyzvazhCdtuWt3c7D7YRDO6dv0celRrKilkMaQsPDSy0XjHS8wiRvMJt9TQyjEjZsy1I7IaG6iKhm9kG6nhx-2B8DJtAMjvpx-2BA-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">
</div>
_______________________________________________<br>
hibernate-issues mailing list<br>
<a href="mailto:hibernate-issues@lists.jboss.org" target="_blank">hibernate-issues@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/hibernate-issues" rel="noreferrer" target="_blank">https://lists.jboss.org/mailman/listinfo/hibernate-issues</a></blockquote></div>