Define base-class for custom query classes.

https://github.com/4teamwork/opengever.core/pull/468