我需要保存BasePermission
的子类
@NodeEntity
public class ExtendedPermission extends BasePermission{
/**
*
*/
private static final long serialVersionUID = 1L;
public static final Permission READ = new ExtendedPermission(1 << 0, 'R'); // 1
public static final Permission WRITE = new ExtendedPermission(1 << 1, 'W'); // 2
public static final Permission CREATE = new ExtendedPermission(1 << 2, 'C'); // 4
public static final Permission DELETE = new ExtendedPermission(1 << 3, 'D'); // 8
public static final Permission ADMINISTRATION = new ExtendedPermission(1 << 4, 'A'); // 16
@GraphId
private Long id;
public ExtendedPermission() {
super(0);
}
protected ExtendedPermission (int mask) {
super(mask);
}
protected ExtendedPermission (int mask, char code) {
super(mask, code);
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
}
尝试保留Entity会出现以下错误:
Caused by: java.lang.RuntimeException: Unsupported value type class java.lang.Character. Supported value types are all java primitives (byte, char, short, int,
long, float, double) and String, as well as arrays of all those types
现在code
的{{1}}为BasePermission
,为什么它被解释为char
。
此外,我写的试图克服这个问题的转换器没有被调用。
Character
转换器注册如下:
public class CharToStringConvertor implements Converter<Character,String>{
@Override
public String convert(Character source) {
return String.valueOf(source);
}
}
public class StringToCharConverter implements Converter<String,Character> {
@Override
public Character convert(String source) {
return source.toCharArray()[0];
}
}
其他转换器按预期注册为调用,但未调用CharToString,反之亦然。