Add Query import to generated table class files.

This will prevent a pretty common error where people forget to import
the query class.

Fixes #3963