DAOs
DAOs are classes where you can create, read, update, and delete data in your database according to a model.
note
📣  All commands have to be run in the api service (make api).
Generate#
This command will regenerate the TDBM models and DAOs.
Like models, TDBM generates two kinds of classes. For instance:
BaseUserDao.UserDaothat extendsBaseDao.
The first class contains most of the methods allowing you to interact with the corresponding table in the database.
You cannot modify it, but instead, edit the second class as TDBM does not override it.
Save / Update#
The base DAO provides a method save which takes the model instance as parameter:
note
📣  TDBM generates the primary key.
Delete#
The base DAO provides a method delete which takes the model instance as parameter:
note
📣  This method also takes a boolean argument for cascade deletion. However, it would be best to handle such scenarios with Use Cases composition.
Get By#
The base DAO provides methods for retrieving a model from the primary key and unique properties:
Find All#
The base DAO provides the method findAll:
note
📣  This method returns a ResultIterator, a sort of array of instances. See the Lists
guide for more details.
Find#
The base DAO provides the method find:
note
📣  If a parameter's value is null, TDBM
automatically removes the corresponding conditions in the first argument.
note
📣  This method returns a ResultIterator, a sort of array of instances. See the Lists
chapter for more details.