company logo

DBBaseContext :: doBeforeStore - Before store handler

The before store handler is called before storing instance data to the transaction or database (DBP_Store event). The event handler is typically used to perform application consistency checks for the instance or update derived persistent data before storing the instance. To prevent infinite loops, do never call save() in a doBeforeStore() handler.

One may also update derived fields in the doBeforeModify() event handler, which acts on the property level rather than on the instance level. This allows more precisely detecting changes on specific fields. In case of copying or duplicating instances, the context instance provides a reference context (TypeContext::referenceContext()), which refers to the source instance.

The before store handler can deny creating the data instance by returning an error ( any value >0 ).

The handler may be overloaded in specialized type context class implementations.

Return value:  Execution error ( int32  )

The value is usually returned from context functions or actions in order to report the result of execution. The variable may contain following values:

  • -1: function/action not executed
  • 0: function executed normally
  • 1-9: Function executed with errors. Error codes depend on the function/action called.

Implementation details

int32 DBBaseContext  :: doBeforeStore (  )