现在有三个hibernate的xml文件:Role.hbm.xml,User.hbm.xml,SystemPrivilege.hbm.xml。
能够在数据库中创建4个表:itcast_role,itcast_user,itcast_systemprivilege,itcast_user_role。
但是无法创建itcast_role_systemPrivileges表,不知道什么原因?三个配置文件如下:Role.hbm.xml:<hibernate-mapping package="cn.itcast.bbs.domain">
<class name="Role" table="itcast_role">
<cache usage="read-write" /> <id name="id" column="id_">
<generator class="uuid" />
</id>
<property name="name" column="name_" length="64" />
<property name="description" column="description_" length="255" />
<property name="defaultForNewUser" column="defaultForNewUser_" /> <!-- order-by="1"只是为了用 LinkedHashSet 存放结果,就可以有一定的顺序了 -->
<set name="systemPrivileges" table="itcast_role_systemPrivileges" lazy="false" order-by="1">
<cache usage="read-write"/>
<key column="roleId_"></key>
<many-to-many class="SystemPrivilege" column="systemPrivilegeId_" />
</set>
</class>
</hibernate-mapping>

解决方案 »

  1.   

    User.hbm.xml:<hibernate-mapping package="cn.itcast.bbs.domain">
    <class name="User" table="itcast_user">
    <cache usage="read-write"/> <id name="id" column="id_" length="45">
    <generator class="uuid" />
    </id>
    <property name="loginName" column="loginName_" length="128" />
    <property name="password" column="password_" length="128" />
    <property name="email" column="email_" length="128" /> <property name="nickname" column="nickname_" length="128" />
    <property name="gender" column="gender_" type="genderType" length="16" />
    <property name="avatar" column="avatar_" length="204800" />
    <property name="signature" column="signature_" length="255" /> <property name="registrationTime" column="registrationTime_" type="timestamp" />
    <property name="lastVisitTime" column="lastVisitTime_" type="timestamp" />
    <property name="lastVisitIpAddr" column="lastVisitIpAddr_" length="15" /> <property name="topicCount" column="topicCount_" />
    <property name="articleCount" column="articleCount_" /> <property name="locked" column="locked_" />
    <property name="autoLoginAuthKey" column="autoLoginAuthKey_" length="128" /> <!-- <property name="activationKey" column="activationKey_" length="45" /> -->
    <set name="roles" table="itcast_user_role" lazy="false">
    <cache usage="read-write"/>
    <key column="userId_"></key>
    <many-to-many class="Role" column="roleId_"/>
    </set>
    </class>
    </hibernate-mapping>
      

  2.   

    SystemPrivilege.hbm.xml:<hibernate-mapping package="cn.itcast.bbs.domain">
    <class name="SystemPrivilege" table="itcast_systemprivilege">
    <cache usage="read-only"/>
    <id name="id" column="id_">
    <generator class="uuid" />
    </id>
    <property name="name" column="name_" />
    <property name="action" column="action_" length="64" />
    <property name="resource" column="resource_" length="64" />
    </class>
    </hibernate-mapping>
      

  3.   

    不清楚 本来就不用HIBERNATE生成表 多对多就更够戗了。。 有些时候貌似多对多也不用中间表吧。。
      

  4.   

    这个表itcast_user_role是可以生成的,但是itcast_role_systemPrivileges为什么无法生成呢?