Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/384.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java JdbcMutableAclService+;HSQLDB=更新ACL时出现BadSqlGrammarException_Java_Spring_Spring Security_Hsqldb - Fatal编程技术网

Java JdbcMutableAclService+;HSQLDB=更新ACL时出现BadSqlGrammarException

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

我将SpringACL与MySQL一起使用,效果很好。但是,在集成测试中,当我使用HSQLDB引擎时,当我调用
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());
}