Fixed multiple modules for one mimetype support

Instead of just getting the first object from the database, we get the
object with the correct table name. Previous version does not work well
for mimetypes with multiple modules.