I have a base class
@MappedSuperclass
@Data //lombok annotation for getters/setter
public class BaseEntity implements Identifiable<Long> {
@Id @GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@Version
private Long version;
}
For any derived class Spring Data REST returns JSON without "id" and "version" attributes.
I found 2 solutions:
- Projections.
Add getters/setters with another names:
public Long getRevision() { return version; } public void setRevision(Long revision) { this.version = revision; } public Long getIdentifier() { return id; } public void setIdentifier(Long identifier) { this.id = identifier; }
Both solutions look like hacks. Does better approach exist?