表和映射表之间的关系设置使用连接

时间:2010-04-28 16:14:10

标签: java hibernate hql

我有两个表,一个“模块”表和一个“StaffModule”我想显示一个模块列表,工作人员出现在staffmodule映射表中。

我试过

from Module join Staffmodule sm with ID = sm.MID

没有运气,我收到以下错误

  

预计加入的路径!

然而我认为我有正确的联接也允许这样但显然不能任何人帮助

StaffModule HBM

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated Apr 26, 2010 9:50:23 AM by Hibernate Tools 3.2.1.GA -->
<hibernate-mapping>
  <class name="Hibernate.Staffmodule" schema="WALK" table="STAFFMODULE">
    <composite-id class="Hibernate.StaffmoduleId" name="id">
        <key-many-to-one name="mid" class="Hibernate.Module">
            <column name="MID"/>
        </key-many-to-one>
      <key-property name="staffid" type="int">
        <column name="STAFFID"/>
      </key-property>
    </composite-id>
  </class>
</hibernate-mapping>

和Module.HBM

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated Apr 26, 2010 9:50:23 AM by Hibernate Tools 3.2.1.GA -->
<hibernate-mapping>
  <class name="Hibernate.Module" schema="WALK" table="MODULE">
    <id name="id" type="int">
      <column name="ID"/>
      <generator class="assigned"/>
    </id>
    <property name="modulename" type="string">
      <column length="50" name="MODULENAME"/>
    </property>
    <property name="teacherid" type="int">
      <column name="TEACHERID" not-null="true"/>
    </property>
  </class>

希望有足够的信息!

并提前致谢。

0 个答案:

没有答案