使用@Enumerated处理空DB值

时间:2017-08-09 01:17:14

标签: java hibernate jpa

我有这样的枚举:

# OK: SINGLE-quoted jq script:
PS> '{ "foo": "bar" }' | jq '. as $cols | .foo'
"bar"

# BROKEN: DOUBLE-quoted jq script: PowerShell expands `$cols` up front, 
#         resulting in an empty string, if no such PowerShell variable exists. 
#         jq then effectively sees '. as  | .foo', which explains the syntax error.
PS> '{ "foo": "bar" }' | jq ". as $cols | .foo"
jq: error: syntax error, unexpected '|', expecting '$' or '[' or '{' (Unix shell quoting issues?) at <top-level>, line 1:
. as  | .foo      
jq: 1 compile error

和POJO类如:

public enum OverallResult {
    ACCEPT,
    REJECT,
}

所以问题是我得到了

@Enumerated(EnumType.STRING)
@Column(name = "OVERALL_RESULT", insertable = false, updatable = false)
private OverallResult overallResult;

看起来它在数据库中遇到NULL值问题。

知道如何解决这个问题吗?

由于

0 个答案:

没有答案