This feature still is quite basic but it will soon be improved.
Currently you can only attach event handlers to the ObjectContainer:
01namespace com.db4odoc.f1.nq 02
{ 03
public class NQExample 04
{ 05
public void SetOptimization(ObjectContainer container) 06
{ 07
NativeQueryHandler handler = ((YapStream)container).GetNativeQueryHandler(); 08
handler.QueryExecution += OnQueryExecution; 09
handler.QueryOptimizationFailure += OnQueryOptimizationFailure; 10
}