Java JdbcMutableAclService+;HSQLDB=更新ACL时出现BadSqlGrammarException
我将SpringACL与MySQL一起使用,效果很好。但是,在集成测试中,当我使用HSQLDB引擎时,当我调用Java JdbcMutableAclService+;HSQLDB=更新ACL时出现BadSqlGrammarException,java,spring,spring-security,hsqldb,Java,Spring,Spring Security,Hsqldb,我将SpringACL与MySQL一起使用,效果很好。但是,在集成测试中,当我使用HSQLDB引擎时,当我调用aclService.updateAcl(myAcl)时,它会引发以下异常: 整个代码片段是: ObjectIdentity oi = new ObjectIdentityImpl(domainObject); MutableAcl acl = aclService.createAcl(oi); acl.setOwner(new PrincipalSid(SYSTEM_PRINCIPAL
aclService.updateAcl(myAcl)
时,它会引发以下异常:
整个代码片段是:
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
字段是类JdbcMutableAclService
的实例。请注意,在MySQL上,一切正常
弹簧3.1.2.释放
编辑:
实际上,只有当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());
}
根据我的一般经验(老实说,我从未尝试过使用HSQLDB的SpringACL),并且根据PreparedStatement何时与HSQLDB一起使用,必须添加批处理。因此,我想您不能在HSQLDB上测试SpringACL
@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());
}