Projects:Enable Read-Only Pool per report/Developers guide
The OBDal instance (available through OBDal.getInstance()) is the main entrance point for retrieving and storing business objects in the database in a validated and secure way. It provides the following functions:
- save: stores a new business object in the database or an existing business object is updated. For existing business object it is not required to call this method as Hibernate does automatic dirty checking.
- get: retrieves a single business object using its id. There are two versions: one using the class name (of the generated business object) and one using the entity name.
- remove: delete a business object from the database, the actual database delete is done at commit time.
- create OBCriteria: OBCriteria objects are used for querying.
- commitAndClose and rollbackAndClose: these methods can be used to implement custom transaction handling. Normally this is done by the environment (Openbravo web container or Openbravo test).
The OBDal class allows to access to the read-only database (pool). In this case, the instance must be retrieved with the OBDal.getReadOnlyInstance() method. It is important to note that if the read-only pool is not configured, this method will use the standard pool to get the database connections.
Once the read-only pool is configured, there are two ways to override OBDal.getReadOnlyInstance() behavior:
- Creating a record in Data Pool Selection, which associates a database pool with a particular report.
- Using the Default DB Pool used by reports Preference, which defines the default pool returned by OBDal.getReadOnlyInstance() if no entry in Data Pool Selection is made for the current Process.