The generated N1QL queries currently don't filter on the type at all. Add a criteria to the WHERE clause that checks the field holding type information is matching the entity fully qualified class name. Add a placeholder for inline N1QL queries that can be replaced by the same type information criteria.