Package onl.ycode.stormify
Interface CRUDTable
public interface CRUDTable
A common interface for all tables that can perform CRUD operations.
By implementing this interface, a class can perform basic CRUD operations, such as create, update, delete, directly on the object itself, without the need to call stormify() manually, and reduce the clutter.
-
Method Summary
Modifier and TypeMethodDescriptiondefault void
create()
Create a new object in the database.default void
delete()
Delete an existing object from the database.default <T> List<T>
getDetails
(Class<T> detailType) In a parent-child relationship, get all the children that have as parent the current object.default <T> List<T>
getDetails
(Class<T> detailType, String propertyName) In a parent-child relationship, get all the children that have as parent the current object.default void
populate()
Populate the fields of the object from the database manually.default String
Get the database table name of the object.default void
update()
Update an existing object in the database.
-
Method Details
-
create
default void create()Create a new object in the database. -
update
default void update()Update an existing object in the database. -
delete
default void delete()Delete an existing object from the database. -
tableName
Get the database table name of the object.- Returns:
- The table name of the object.
-
populate
default void populate()Populate the fields of the object from the database manually. -
getDetails
In a parent-child relationship, get all the children that have as parent the current object.- Type Parameters:
T
- The type of the details.- Parameters:
detailType
- The type of the details.- Returns:
- A list with all the details of the current object.
-
getDetails
In a parent-child relationship, get all the children that have as parent the current object.If more than one parent-child relationship exists, with the same type, use this method to specify the property name that holds the actual relationship.
- Type Parameters:
T
- The type of the details.- Parameters:
detailType
- The type of the details.propertyName
- The name of the property that holds the details.- Returns:
- A list with all the details of the current object.
-