Openbravo Architecture

Openbravo 2.50: Data Access Layer in the overall Openbravo Architecture

donderdag 8 januari 2009

This post discusses the architecture of the new Data Access Layer and its place in the rest of the current and future envisioned architecture.

The image below illustrates the different layers of the Openbravo architecture. Part of the architecture is delivered in 2.50 other parts will be delivered in future releases.


The Data Access Layer (DAL) uses the application dictionary as the basis for its operations. The application dictionary defines the tables, columns and data types in Openbravo (for example Business Partner, Sales Order, etc.). The Data Access Layer uses the application dictionary for two purposes:

  • to generate Java business objects at development time
  • at runtime to generate a Hibernate mapping to persist the business objects
To perform these two steps the DAL reads the application dictionary from the database and builds an in-memory representation. This is called the runtime model. Having the model in-memory makes it possible to use the model in an efficient way for different kinds of tasks (security checking, validation, etc.)

So at development time Java business objects are generated for each table in the system. The columns of the table corresponds to properties (getters/setters) in the generated Java class. The foreign key columns are present as references to other generated business objects. The business object generation is done as part of the standard Openbravo build steps. The generated classes can be found in the src-gen folder in the openbravo development project.

At runtime the DAL is responsible for generating the mapping for Hibernate and configuring Hibernate.
The DAL provides an API to store, query and remove business objects from the database. This DAL service layer takes care of validation and security checks. In a future Openbravo release this API will be used to develop the business logic layer. The business logic layer will replace the current stored procedures and triggers. The business service layer will provide an API to the outside world to run business logic within Openbravo.

Two other interesting components are also present: UI and Web Services. Integrating the DAL into the UI will be done in a future release. In 2.50 we provide a REST webservice layer which provides CRUD operations on all Openbravo business objects. I will discuss the REST Webservice support in the next post.

At runtime the DAL takes care of transaction handling and providing a context in which all DAL operations run. The transaction handling is done using the open-session-in-view pattern whereby the developer in general does not need to take care of transaction handling explicitly (but he/she can ofcourse when required). The Openbravo context object makes it easy for a developer to retrieve the current user object and other context information.

The following parts of the new architecture are delivered as part of 2.50:
  • Runtime Model
  • Generation of Business Object and Hibernate Mapping
  • DAL API
  • REST Webservices
  • Transaction Handling and User Context
The other components will be delivered as part of subsequent releases.

For more information here are two wiki documents which give some more details:
This hopefully gives a feel for the overall current and future architecture of Openbravo. In the next blog post I will discuss the new REST Webservice functionality in Openbravo 2.50.

Openbravo 2.50: New Architectural Developments: Data Access Layer and REST Webservices

maandag 5 januari 2009

The Openbravo 2.50 release contains a number of new architectural developments which can be of great interest for Openbravo developers and system integrators.

The first main development is the Data Access Layer which provides the application developer with an object-oriented view on the Openbravo database. The Data Access Layer is also used to support new XML conversion functionality which allows the application developer to convert business objects from and to XML. The XML conversion logic again forms the basis for export and import of Client data and new REST webservices functionality provided in Openbravo 2.50.

I will cover these new developments in a series of posts which will be published the coming weeks.

In this first post for Openbravo, let me also introduce myself. I am responsible for some of the new architecture developments at Openbravo, both design and development. My background is both in ERP system as well as technical Java coding. Next to Openbravo I am involved in open source development as a committer of the Eclipse Modeling Framework project. I am looking forward to work further on extending the Openbravo architecture and hope for extensive feedback from the community on the new developments in the Openbravo 2.50 release.

The starting point for the blog series will be the new Data Access Layer (DAL). The DAL provides an object-oriented layer over the Openbravo database. It is based on Hibernate using model-driven code generation techniques. The Data Access Layer provides the application developer with the following functionality:

  • type safe querying and retrieval of business objects from the database.
  • a convenient API to update or create new data in the database.
  • a type safe interface to update information of a business object, increased productivity by making the properties of a business object directly visible through getters and setters (in the development environment).
  • transaction and context handling.
  • security and validation checking.
  • automatically maps new entries in the application dictionary to database tables and columns.
  • generates Java class business objects (and their associations) on the basis of the Application Dictionary model.

With the DAL the application developer does not need to type in tedious/type-unsafe sql queries. He/she can make use of the code completion and compile time checking functionality of his/her development environment. The Data Access Layer can also be easily integrated in test driven development approach as it operates independent from servlet containers such as Tomcat.

The Data Access Layer uses an in-memory representation of the application dictionary (the runtime model). This runtime model is used to convert business objects from and to XML. The XML conversion functionality is very usefull for integration scenarios. It is the basis for new functions such as the export and import of Client data and Webservice functionality. The XML Conversion functionality will be discussed in a separate technical post.

The 2.50 release also provides completely new REST webservice functionality. The REST webservice offers a common APO to query, retrieve and update all Openbravo business objects (persisted in the database). The REST webservice can be reached using simple (REST) URI's making it easy to use, test and try out. The Openbravo REST framework is easy to extend and allows you to add your own (REST) webservices. I will spend a separate post on REST Webservices and how to create your own WebService.

This post was just an introduction to give you a feel for what is coming in 2.50. The next posts will dive into more details, starting with an architecture description followed by the standard Hello World DAL example!