ODB supports Triggers for both local & Client/Server mode.

Click Here to see how a server side trigger can update objects on the client side.

To add a trigger in local mode, the first step is to build a class that implements one of the trigger interface

Insert Trigger

public interface IInsertTrigger {
    public boolean beforeInsert(Object object);
    public void afterInsert(Object object,OID oid,long position);

Update Trigger

public interface IUpdateTrigger {   
    public boolean beforeUpdate(Object oldObject,Object newObject,OID oid);
    public void afterUpdate(Object oldObject,Object newObject,OID oid);

Delete Trigger

public interface IDeleteTrigger {
    public boolean beforeDelete(Object object,OID oid);
    public void afterDelete(Object object,OID oid);

Select Trigger

public interface ISelectTrigger {
    public void afterSelect(Object object,OID oid);

Insert Trigger Example

public class MyTrigger implements IInsertTrigger {
    public void afterInsert(Object object, OID oid, long position) {
        System.out.println("after insert object with id "+oid+"("+object.getClass().getName()+")");
    public boolean beforeInsert(Object object) {
        System.out.println.println("before inserting " + object);
        return true;

Then use the ODB API to register the trigger:

odb = open("trigger.odb");
odb.addInsertTrigger(new MyTrigger());
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License