尝试使用MutableAclService.createAcl(ObjectIdentity objectIdentity)
.
问题是ObjectIdentity
使用Serializable
类型作为标识符。同时,我的域String
为此目的使用类型。id 是这样生成的:
String id = UUID.randomUUID().toString();
然后我尝试使用以下结构添加 ACL:
ObjectIdentity identity = new ObjectIdentityImpl(clazz, id);
aclService.createAcl(identity);
之后我得到以下异常:
java.lang.NumberFormatException:对于输入字符串:“ad169805-a2d1-4324-ba11-c98cc679e594”
我发现 Spring Security ACL 使用Long
类型作为标识符。
所以,问题是:
- 在这种情况下,最佳实践是什么(我是否需要使用,例如,我的对象的哈希码作为标识符,或者其他)?
- 为什么
Serializable
处处提到,而实际上却一定是长篇大论?
PS 标识符的 SQL 数据类型也是数字 - bigserial。