public class Toponym {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
public int id;
@Column(columnDefinition="TEXT default ''", nullable = false)
public String name;
}
public class LevelOneEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
public int id;
@Column(columnDefinition = "boolean default false", nullable = false)
private boolean archived;
}
public class LevelTwoEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
public int id;
@Column(columnDefinition = "boolean default false", nullable = false)
private boolean archived;
}
These two classes definitely have some boilerplate code. If multiple inheritance were a reality, I'd organize two mixins here: IdMixin and ArchivedMixin. Therefore classes would contain no bodies at all. But in Java it is not possible.
It may be possible to use multiple interfaces but they can't contain the code itself if I'm not mistaken.
How to cope with such a problem in Java?