What is a DB API?


DAO layer

For the project that have database, a common recommended way to access it is to use a Data Access Object layer. This DAO layer is used to wrap the complexity of accessing the database data and protocol by fa├žaded the access with an interface operating with objects.
If we look a little closer what are the functionalities this layer will provide to the users, we can classified those in two distinct categories:
  • Entity (table) specific functions. Generally associated with CRUD functions;
  • Business related functions. Ex: special select, access to store proc...
Developing the entity specific functions of a DAO layer is a tedious task:
  • error prone, lots of places to maintain in case of changes in the model;
  • most of the code developped is linked with the database model and has little with the business added value.

DB API

MinuteProject helps the developer by generating the model's DB API which is a default API for a data model.
MinuteProject generates a default DAO layer for the model with CRUD+ functionalities.
  • standard CRUD;
  • search on Example/Prototype;
  • update on Example/Prototype;
  • partial Load of data;
    • Loads just couple of fields of a entity or its associated parents
  • load part of the object graph;
  • pagination load.
This API is easy to integrate: Service can be quickly be build on the top of it.
This API is easy to extend:
  • Other DAO using partially or completely the generated code can be quickly developed;
  • Extension on top of ORM maps are also feasible. The user can use the mappings to write his/her specific queries.

DB API available methods

Definition

Mask bean

Are used for indicating which field is to be taken into account. Domain Object mask specifies the fields corresponding to database column with no null value.
Those non-null field can be further processed according to the contect (DAO method) there are used.
Example:
a mask can indicate the field to
1) retrieve (or the opposite not to retrieve) on a table, and thus create the correct sql statement.
2) set to null (or the opposite not empty) in a where clause.

Positive/negative beans

In the context of BSLA DAO layer.
A positive bean is a mask, used for where clause, whose non-null attributes are to be used by the DAO method to express the value to use in the query.
A negative bean is a mask, used for where clause, whose non-null attributes are to be used by the DAO method to express which field are null to use in a query.

What and Where parts

TODO
Simple Domain Object
TODO
Domain Object With Parents
TODO

Methods

search on prototype

Based on a positive bean:
Return a list of Domain Object that matches the criteria passed in the Domain Object positive bean.

Example:
Get all employees that have the name 'ADAM'.

Based on positive and negative beans:
Return a list of Domain Object that matches the criteria passed in the Domain Object positive bean and null criteria that are set in the negative bean mask.

Example:
get all employees where that are still present (where the departure date is empty).

delete / update on prototype

TODO

search graph

TODO

exists

TODO

exists where conditions are

TODO

partial load with parent

TODO

assign

TODO

assign use cache

TODO

affect

TODO

affect use cache

TODO

search distinct on prototypes

TODO

cascade insert

TODO

load paginated

TODO

Implementation

Spring/hibernate
Spring/JPA
Spring/iBatis