我有一个奇怪的行为。我有一个实体,它使用@Embeddables 来存储类型信息(TerminalType)。这种类型应该只有固定值。因此,我创建了 CLIENT、BROWSER、EXTRENAL 等常量。
@Embeddable
@Audited
public class TerminalType extends DomainValue {
private static final long serialVersionUID = 1L;
public static final TerminalType CLIENT = new TerminalType("CLIENT");
public static final TerminalType BROWSER = new TerminalType("BROWSER");
public static final TerminalType EXTERNAL = new TerminalType("EXTERNAL");
protected TerminalType() {
}
protected TerminalType(String id) {
this.value = id;
}
@Column(name = "VALUE")
private String value;
/* only getter for the value ... */
}
然后在实体终端中使用此类
@Entity
@Audited
public class Terminal {
private static final long serialVersionUID = 1L;
@Id
protected String terminalName;
@NotNull
@Embedded
@AttributeOverride(name = "value", column = @Column(name = "TERMINAL_TYPE"))
protected TerminalType type;
protected Terminal() {
}
/* setter and getter ... */
}
问题是值常量有时会发生变化。应用程序可以运行几个小时,但一段时间后,常量 CLIENT 的值为“BROWSER”。
我不知道什么/谁改变了常数?任何想法都会有所帮助!谢谢!