3. ModelService
ModelService manages the lifecycle of the models themselves, not just the data.
register(Model model)
- Function: Registers a new dynamic model at runtime.
- Scenario: User defines a new "Form" in the UI -> You create a
Modelobject -> Register it -> Framework creates the table.
update(Model model)
- Function: Updates the database schema (DDL) to match the provided model.
- Behavior:
- Adds missing columns.
- Updates column types/comments.
- Creates/Updates indexes.
- Safe: It generally does not drop columns to prevent data loss.
getDataManager(Class<?> entityClass)
- Function: The factory method to get the
DataManagerfor your business logic. - Example:
DataManager<Long> dm = modelService.getDataManager(Product.class); dm.insert(new Product("Phone"));