Expected Behavior
In JdbcMutableAclService add getters for the following attributes:
insertSidselectClassPrimaryKeyselectSidPrimaryKey
Or implement standard identity query mechanism.
Current Behavior
There is no possibility to retrieve the values of the attributes in a subclass.
Context
The Spring Security ACL don't support H2 (#11231). In the JdbcMutableAclService there is a classIdentityQuery and sidIdentityQuery attributes that contain the following query: call identity(). The H2 don't support this. I don't know any select to retreive the generated id. I would like to create a subclass and override the createOrRetrieveClassPrimaryKey and createOrRetrieveSidPrimaryKey methods. In this methods I need the insertSid, selectClassPrimaryKey and selectSidPrimaryKey values.
Much better solution is to use a standard identity query mechanism:
KeyHolder keyHolder = new GeneratedKeyHolder();
this.jdbcOperations.update(connection -> {
PreparedStatement ps =
connection.prepareStatement(insertSid,
Statement.RETURN_GENERATED_KEYS);
ps.setBoolean(1, sidIsPrincipal);
ps.setString(2, sidName);
return ps;
}, keyHolder
);
Assert.isTrue(TransactionSynchronizationManager.isSynchronizationActive(), "Transaction must be running");
return (Long) keyHolder.getKeys().get("id");
You find my solution here: https://github.com/vicziani/jtechlog-spring-security-acl/blob/master/src/main/java/jtechlog/acltutorial/H2JdbcMutableAclService.java
(I also replaced the deprecated queryForList method - using varargs.)