MySQL と一緒に Spring ACL を使用していますが、正常に動作します。ただし、統合テストで HSQLDB エンジンを使用すると、呼び出すaclService.updateAcl(myAcl)
と次の例外がスローされます。
Caused by: org.springframework.jdbc.BadSqlGrammarException:
PreparedStatementCallback; bad SQL grammar
[insert into acl_entry (acl_object_identity, ace_order, sid, mask, granting,
audit_success, audit_failure)values (?, ?, ?, ?, ?, ?, ?)]; nested exception is
java.sql.SQLException: statement is not in batch mode
...
java.sql.SQLException: statement is not in batch mode
...
org.hsqldb.HsqlException: statement is not in batch mode
コード スニペット全体は次のとおりです。
ObjectIdentity oi = new ObjectIdentityImpl(domainObject);
MutableAcl acl = aclService.createAcl(oi);
acl.setOwner(new PrincipalSid(SYSTEM_PRINCIPAL_SID));
if (parentObject != null) {
Acl parent = aclService.readAclById(new ObjectIdentityImpl(parentObject));
acl.setParent(parent);
}
aclService.updateAcl(acl);
aclService
フィールドは class のインスタンスですJdbcMutableAclService
。MySQL ではすべて正常に動作することに注意してください。
春の 3.1.2.RELEASE。
編集:
実際には、空のリストが返された場合にのみ例外がスローacl.getEntries()
されました (ACL が作成されたばかりであるため、ACE は含まれていません)。のデフォルトの実装を拡張し、空のリストを呼び出して問題を引き起こすメソッドをJdbcMutableAclService
オーバーライドすることで、問題を修正しました。この問題の本当の原因はまだわかりませんが、なんとか機能させることができました。これが私の簡単な解決策です:updateAcl()
createEntries()
@Override
public MutableAcl updateAcl(MutableAcl acl) throws NotFoundException {
if (acl.getEntries().size() > 0) {
return super.updateAcl(acl);
}
Assert.notNull(acl.getId(), "Object Identity doesn't provide an identifier");
// Change the mutable columns in acl_object_identity
updateObjectIdentity(acl);
// Retrieve the ACL via superclass (ensures cache registration, proper retrieval etc)
return (MutableAcl)super.readAclById(acl.getObjectIdentity());
}