Question Similarity i.e. this is not a duplicate
N.B: there are a number of questions which seem similar to this one:
What is the exact meaning of the JPA @Entity annotation?
What is an Entity? Why is it called Entity?
But they either refer to the 'Entity Framework' or the '@Entity' annotation (which is apparently used to stated that a class can be mapped to a table). Although my question may appear similar to these it is slightly different and so should not be considered a duplicate.
My actual question
I am working with a codebase which has a package called 'com.xxx.yyy.entities'. This package contains a number of classes all with essentially the same structure:
An example of one of the simplest classes is below:
public class Competition {
private String id;
private String name;
public String getId() { return id; }
public void setId(String id) { this.id = id; }
public String getName() { return name; }
public void setName(String name) { this.name = name; }
public String toString() {
return "{" + "" + "id=" + getId() + "," + "name=" + getName() + "}";
}
}
The classes contained within the 'entities' package are never actually instantiated but instead are always serialised/deserialised to/from JSON (this particular project uses GSON to achieve this).
My questions are:
In the traditional sense, an "Entity" is an object that gets persisted to a relational DB. Typically (but not necessarily) an Entity maps to a table. In a more general sense, en Entity represents the implementation of a mapping to other serialised objects, like JSONs.
I think the word comes from Entity–relationship (ER) models, and again, this has to do with how you represent information in a data model, typically a relational database. It's not a Java-only concept, as ER data modelling predates Java by decades.