Cayenne can "execute" any object as a query as long as it implements Query interface and provides meaningful implementation of either Query.route(...) and/or Query.createSQLAction(SQLActionVisitor)} methods. So users can extend/customize queries if they need to. Custom implementations would normally either create a query from a standard Cayenne set and delegate the execution to it (acting as a sort of "query builder"), or can implement its own non-standard SQLAction.