I have a configuration of hibernate with two tables in Mysql and the files of configuration of Pojo are the following:
<hibernate-mapping>
<class name="empresa.Departamentos" table="departamentos" catalog="empresa2" optimistic-lock="version">
<id name="deptno" type="int">
<column name="deptno" />
<generator class="assigned" />
</id>
<property name="dnombre" type="string">
<column name="dnombre" length="15" />
</property>
<property name="loc" type="string">
<column name="loc" length="15" />
</property>
<set name="empleadoses" table="empleados" inverse="true" lazy="true" fetch="select">
<key>
<column name="deptno" not-null="true" />
</key>
<one-to-many class="empresa.Empleados" />
</set>
</class>
</hibernate-mapping>
<hibernate-mapping>
<class name="empresa.Empleados" table="empleados" catalog="empresa2" optimistic-lock="version">
<id name="empno" type="short">
<column name="empno" />
<generator class="assigned" />
</id>
<many-to-one name="departamentos" class="empresa.Departamentos" fetch="select">
<column name="deptno" not-null="true" />
</many-to-one>
<property name="apellido" type="string">
<column name="apellido" length="10" />
</property>
<property name="oficio" type="string">
<column name="oficio" length="10" />
</property>
<property name="dir" type="java.lang.Short">
<column name="dir" />
</property>
<property name="fechaalt" type="date">
<column name="fechaalt" length="10" />
</property>
<property name="salario" type="java.lang.Float">
<column name="salario" precision="6" />
</property>
<property name="comision" type="java.lang.Float">
<column name="comision" precision="6" />
</property>
</class>
</hibernate-mapping>
Next, when I execute the following sentence in hql: select e from Empleados e where e.departamentos.deptno in (select d.deptno from Departamentos d where d.loc='London') It gives me the following error: org.hibernate.MappingException: Association references unmapped class: empresa.Empleados at org.hibernate.cfg.HbmBinder.bindCollectionSecondPass(HbmBinder.java:2557) at org.hibernate.cfg.HbmBinder$CollectionSecondPass.secondPass(HbmBinder.java:2808) at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:70) at org.hibernate.cfg.Configuration.originalSecondPassCompile(Configuration.java:1695) at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1424) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1844) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1928) Regards, Javier