【发布时间】:2015-10-28 20:37:01
【问题描述】:
我的 JPA 实体如下
@Entity
public class OptionsEntity implements Serializable {
@Id
@Column(name="OptionNumber",
nullable=false,
insertable=true,
updatable=true,
length=20)
private String optionNumber;
@Basic
@Column(name="OptionName",
nullable=false,
insertable=true,
updatable=true,
length=100)
private String optionName;
@Basic
@Column(name="OptionStatusCode",
nullable=true,
insertable=true,
updatable=true,
length=20)
private String optionStatusCode;
@JsonProperty
@Version
@Column(name="VersionNumber",
nullable=false,
insertable=true,
updatable=true)
private Integer versionNumber;
}
我希望 versionNumber 出现在响应正文中。但是,由于某种原因,它被忽略了。
我正在使用 Spring Boot 和 Spring Data 存储库来检索数据。我不确定它是否在这里扮演任何角色。
Spring Data 谈到了 ETag。但是,让 Spring Security 与 Spring Data 一起参与似乎是一个复杂的过程(由于缓存标头),并且在使用客户端的实体集合(JavaScipt)时也是如此。因此,我想自己处理资源版本控制。
请帮忙。
谢谢!
【问题讨论】:
-
看起来没什么问题。我认为甚至不需要@JsonProperty。您是否尝试将 Integer 更改为原始 int?我假设你有所有领域的公共 getter 和 setter。
标签: jackson spring-boot spring-data spring-data-jpa