Entity is a database table representation.
However it can be created to keep data and querying over it, apart of database.
As table has an unique set of columns inside, so that Entity has unique set of Fields/Columns as well - implemented as interfaces.
Entity like this, may be used as exactly a regular Java object, but the way of storing an inner objects or fields is different - setters and getter are being exposed through interfaces and an internal Map keeps the values.
Each unique column has its own, unique interface, which is being implemented by enties.
This is how relations between tables are recreated into Daobab Entities.
For Java, entity is a column instance as well.
Entity have to inherits particular column interface, otherwise reading or writing will be impossible.
Whole data is stored into a map only through interface method.
Entity used externally, provides a lot of useful methods:
- getters and chained setters
- deep cloning
- conversion to JSON
- proper hashcode and equals
Moreover, if table has Primary Key, a PrimaryKey interface is added. A lot of useful methods are being exposed by this.
Entity also has a column() method, which returns all column interfaces.
It's not enough to add new interface, when a new column is added into a table. Remember to point to a new column into this method as well.
Entity may be protected via Optimistic Concurrency Control.
For special cases, Entity may be upgraded with ExtendedEntity interface.