The Entity Engine works similar to other database-frameworks in the likes of Hibernate. The layer supports a large variety of relational databases and is specifically tailored to the needs of the service layer. The entity engine brings us a few advantages: entity definitions are easy to port, handle the extension of database-tables and offers sophisticated caching and clustering mechanisms. Even multi-tenancy capability is firmly anchored at the database level and is implemented on a database level.

Since the entity engine isolates all database tables from all operations, database queries are always run on a meta-level. For execution a Java class, the “delegator”, comes into play. For performance-reasons, the entity engine also allows the the definition of so-called view entities, which act as selects on complex tables. Once defined, the view entities are created on runtime and stored in memory. They do not differ from the regular tables and also support the known clustering and caching mechanisms.

The real strength of the Entity Engine comes into play when combined with our overarching event architecture.  Like entities, events can be defined that generally recognize a form of action. A good example would be an update operation on a specific field of a table. When an event is triggered, services and entity actions can be run automatically. This allows us to automatically create a new database entry elsewhere inside the database when a product is updated, or a user logs onto the system. An Entity Sync mechanism is also available, which allows the synchronisation of otherwise asynchronous installations, for example within POS systems.

Apart from a technical level, one should also not overlook the entity definition that comes bundled with the SCIPIO ERP standard installation. The entity layout is based on a scientific model, described in detail inside “The Data Model Resource Book Vol. 1-3”. This layout works well as a foundation for all business operations.

Disecting an Entity

An entity is composed of 3 parts:

  1. A declaration
  2. A definition
  3. An implementation


All files containing entity declarations are referenced by the ofbiz-component.xml, which is loaded with the component. All declaration files contain entity definitons as well as view entities & entity event condition actions.


An entity definition consists of basic xml that describe the table or event condition action. These files are composed using XML and define the necessary information needed to invoke a service. The XSD of this kind of files can be found here.

In general, an entity definition will look similar to this:

<entity title="Example table" package-name="com.mycompany.commonapp.sample" entity-name="SampleEntity" table-name="SAMPLE_ENTITY">
   <field name="primaryKeyField" type="id-ne"></field>
   <field name="fieldOne" type="long-varchar"></field>
   <field name="fieldTwo" type="long-varchar"></field>
   <prim-key field="primaryKeyFieldOne" >
   <relation type="one" rel-entity-name="OtherSampleEntity">
      <key-map field-name="foreignKeyOne" rel-field-name="primaryKeyOne" >

Here are more information about the entity model


You use

  • delegator for entity stuff
    Delegator delegator = ctx.getDelegator();
  • dispatcher for running services
    LocalDispatcher dispatcher = ctx.getDispatcher();