select maindynami0_.id as id2_1_, maindynami0_.code as code3_1_, maindynami0_.hierarchyPath as hierarch4_1_, maindynami0_.name as name5_1_, maindynami0_.dynamicSuperclass_id as dynamicS6_1_, maindynami0_.DTYPE as DTYPE1_1_
from DynamicClass maindynami0_ where maindynami0_.DTYPE in ('InstitutionDynamicClass', 'CompanyDynamicClass', 'OrganizationDynamicClass', 'PersonDynamicClass', 'LegalEntityDynamicClass')
and maindynami0_.DTYPE=? and (maindynami0_.dynamicSuperclass_id is null or maindynami0_.DTYPE<>?)