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
).
#
GenerateThis command will regenerate the TDBM models and DAOs.
Like models, TDBM generates two kinds of classes. For instance:
BaseUserDao
.UserDao
that 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 / UpdateThe base DAO provides a method save
which takes the model instance as parameter:
note
📣  TDBM generates the primary key.
#
DeleteThe 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 ByThe base DAO provides methods for retrieving a model from the primary key and unique properties:
#
Find AllThe 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.
#
FindThe 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.