从 JPA 中排除 Class 中的字段

Exclude Field in Class from JPA

我在 JPA 中有一个实体。我最近向我的实体添加了一个字段。我不想保留这个字段。但是,Eclipselink 抱怨它不在 table 中(显然不是)。

如何排除这个 class 不被 JPA 查看。请注意,此字段不能是瞬态的。

您可以添加 JPA 的 @Transient。 注释为 Transient 的字段将不会保留。

一个选项是添加 @Transient annotation if on the other hand you use transient keyword,这意味着该字段不会被序列化。 更多关于 Why does JPA have a @Transient annotation?