[JIRA] (OSJ-345) JPAStorageService readContexts fails under Hibernate 6 with "locking with DISTINCT is not supported"

Ian Young (Jira) jira at shibboleth.atlassian.net
Wed Dec 22 15:59:43 UTC 2021


Ian Young ( https://shibboleth.atlassian.net/secure/ViewProfile.jspa?accountId=557058%3Ae127cb03-43ed-473d-b6ba-592949cb4be8 ) *created* an issue

OpenSAML - Java ( https://shibboleth.atlassian.net/browse/OSJ?atlOrigin=eyJpIjoiZDVhYzMzOTY1M2QxNDI4NGE3MzYzMmJkZTMwODQyOWYiLCJwIjoiaiJ9 ) / Bug ( https://shibboleth.atlassian.net/browse/OSJ-345?atlOrigin=eyJpIjoiZDVhYzMzOTY1M2QxNDI4NGE3MzYzMmJkZTMwODQyOWYiLCJwIjoiaiJ9 ) OSJ-345 ( https://shibboleth.atlassian.net/browse/OSJ-345?atlOrigin=eyJpIjoiZDVhYzMzOTY1M2QxNDI4NGE3MzYzMmJkZTMwODQyOWYiLCJwIjoiaiJ9 ) JPAStorageService readContexts fails under Hibernate 6 with "locking with DISTINCT is not supported" ( https://shibboleth.atlassian.net/browse/OSJ-345?atlOrigin=eyJpIjoiZDVhYzMzOTY1M2QxNDI4NGE3MzYzMmJkZTMwODQyOWYiLCJwIjoiaiJ9 )

Issue Type: Bug Affects Versions: 4.1.1 Assignee: Scott Cantor ( https://shibboleth.atlassian.net/secure/ViewProfile.jspa?accountId=557058%3A5b78efc9-1379-42cc-a3f6-56c6ea3a0007 ) Components: Storage Created: 22/Dec/21 10:59 AM Priority: Trivial Reporter: Ian Young ( https://shibboleth.atlassian.net/secure/ViewProfile.jspa?accountId=557058%3Ae127cb03-43ed-473d-b6ba-592949cb4be8 )

In porting to the Jakarta EE 9 stack in JPAR-186 ( https://shibboleth.atlassian.net/browse/JPAR-186 ) In Progress I came across a place in our JPAStorageService which appears to be incompatible with Hibernate 6.0.0.Beta3, which is the current iteration for that context. It may of course get fixed, but for now our tests fail because the JPAStorageServiceTest’s tearDown method calls

List< String > contexts1 = storageService.readContexts();

The code path includes this:

           // this query uses the distinct keyword, it must use optimistic locking
           return executeNamedQuery(manager, "JPAStorageRecord.findAllContexts" , null , String.class,
                   LockModeType.OPTIMISTIC);

The query in question does indeed include DISTINCT:

   @NamedQuery(name = "JPAStorageRecord.findAllContexts" ,
           query = "SELECT distinct r.context FROM JPAStorageRecord r" ),

This fails with:

java.lang.RuntimeException:
  java.io.IOException:
  java.lang.IllegalStateException:
  org.hibernate.query.IllegalQueryOperationException:
     Locking with DISTINCT is not supported!

In the dev/JPAR-186 branch, I have fixed this by adding the following to tearDown():

       } catch (IOException e) {
           // Temporarily exclude the specific failure case found under Hibernate 6.0.0.Beta3
           if (e.getCause() instanceof java.lang.IllegalStateException ise) {
               if (ise.getCause() instanceof org.hibernate.query.IllegalQueryOperationException ioe) {
                   if ( "Locking with DISTINCT is not supported!".equals(ioe.getMessage())) {
                       // Ignore this one.
                       super.tearDown();
                       return ;
                   }
               }
           }
           throw new RuntimeException(e);
       }
       super.tearDown();

If we’re removing Hibernate this won’t be an ongoing issue. We need to revisit before V5 either way.

( https://shibboleth.atlassian.net/browse/OSJ-345#add-comment?atlOrigin=eyJpIjoiZDVhYzMzOTY1M2QxNDI4NGE3MzYzMmJkZTMwODQyOWYiLCJwIjoiaiJ9 ) Add Comment ( https://shibboleth.atlassian.net/browse/OSJ-345#add-comment?atlOrigin=eyJpIjoiZDVhYzMzOTY1M2QxNDI4NGE3MzYzMmJkZTMwODQyOWYiLCJwIjoiaiJ9 )

Get Jira notifications on your phone! Download the Jira Cloud app for Android ( https://play.google.com/store/apps/details?id=com.atlassian.android.jira.core&referrer=utm_source%3DNotificationLink%26utm_medium%3DEmail ) or iOS ( https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=EmailNotificationLink&mt=8 ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100187- sha1:76abc0a )
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://shibboleth.net/pipermail/commits/attachments/20211222/29378525/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: jira-generated-image-static-comment-icon-ee36bb70-77bd-420b-bc34-65290953fb21
Type: image/png
Size: 1084 bytes
Desc: not available
URL: <http://shibboleth.net/pipermail/commits/attachments/20211222/29378525/attachment-0004.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: jira-generated-image-static-trivial-781c8344-7290-4f56-a33e-87f58e26c953
Type: image/png
Size: 563 bytes
Desc: not available
URL: <http://shibboleth.net/pipermail/commits/attachments/20211222/29378525/attachment-0005.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: jira-generated-image-avatar-9312fe90-2a00-40e6-8a48-94df84937381
Type: image/png
Size: 425 bytes
Desc: not available
URL: <http://shibboleth.net/pipermail/commits/attachments/20211222/29378525/attachment-0006.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: jira-generated-image-static-footer-desktop-logo-a50d66b3-52c6-4171-a82d-9b6ed5c470e5
Type: image/png
Size: 10805 bytes
Desc: not available
URL: <http://shibboleth.net/pipermail/commits/attachments/20211222/29378525/attachment-0007.png>


More information about the commits mailing list