Hibernate 4.3错误与映射文件

时间:2017-05-20 05:45:33

标签: java mysql sql-server hibernate mapping

我收到错误;但是,我无法弄清楚为什么我会收到这个错误。第一个class元素不会给出任何错误,但第二个class元素会给出错误。 (注意:我有其他映射,但它是重复相同的错误所以我不担心把整个文件放在一起)

  

“元素类型”class“的内容必须匹配

     

“(元*,子查询,缓存,同步*,评论,的tuplizer *,(ID |?????复合-ID),鉴别,自然-ID,(版本|时间戳),(财产|?很多-to-一个|一到一个|分量|动态分量|特性|任何|地图|设为|列表|袋| idbag |阵列|原始阵列)的,((合并,子类*)|加入子类* |?工会子*),装载机,SQL插入,SQL更新,SQL-删除,过滤器*,结果集*(查询?|?SQL查询)*)“

任何帮助将不胜感激:

代码

<class name = "cdd.model.User" table = "app_user">
    <id name = "userID" column = "user_id" type = "org.hibernate.type.PostgresUUIDType">
        <generator class="org.hibernate.id.UUIDGenerator"/>
    </id>

    <property name = "email" column = "email" type = "org.hibernate.type.TextType"/>  
    <property name = "fullName" column = "full_name" type = "org.hibernate.type.TextType"/>
    <property name = "passwordHash" column = "password_hash" type = "org.hibernate.type.TextType"/>
    <property name = "centre" column = "centre" type = "org.hibernate.type.TextType"/>
    <property name = "accessLevel" column = "access_level" type = "org.hibernate.type.IntegerType"/>

    <set name="acceptedQuestions" table="accepted_questions_by_user">
        <key column="user_id"/>
        <many-to-many column="question_id"
                      unique="true"
                      class="cdd.model.Question"/>
    </set>
</class>

<class name = "cdd.model.Category" table ="category" > 
    <!--> Primary Key <!-->  
    <id name ="categoryID" column = "category_id" type = "org.hibernate.type.PostgresUUIDType">
        <generator class = "org.hibernate.id.UUIDGenerator" />
    </id>

    <property name = "title" column = "title" type = "org.hibernate.type.TextType"/>
    <property name = "description" column = "description" type = "org.hibernate.type.TextType" />

    <join table = "category" >
        <key column = "category_id"/>
        <many-to-one name="category" column = "category_id" not-null = "true"/>
    </join>

    <set name = "questions" table = "category_questions" cascade = "all"  inverse = "true">
        <key column = "category_id" not-null = "true" />
        <one-to-many class = "cdd.model.Question"/> 
    </set>

</class>

1 个答案:

答案 0 :(得分:1)

在设置

之后放置连接标记部分
<class name = "cdd.model.User" table = "app_user">
    <id name = "userID" column = "user_id" type = "org.hibernate.type.PostgresUUIDType">
        <generator class="org.hibernate.id.UUIDGenerator"/>
    </id>

    <property name = "email" column = "email" type = "org.hibernate.type.TextType"/>  
    <property name = "fullName" column = "full_name" type = "org.hibernate.type.TextType"/>
    <property name = "passwordHash" column = "password_hash" type = "org.hibernate.type.TextType"/>
    <property name = "centre" column = "centre" type = "org.hibernate.type.TextType"/>
    <property name = "accessLevel" column = "access_level" type = "org.hibernate.type.IntegerType"/>

 <set name="acceptedQuestions" table="accepted_questions_by_user">
        <key column="user_id"/>
        <many-to-many column="question_id"
                      unique="true"
                      class="cdd.model.Question"/>
 </set>
</class>
<class name = "cdd.model.Category" table ="category" > 

    <id name ="categoryID" column = "category_id" type = "org.hibernate.type.PostgresUUIDType">
        <generator class = "org.hibernate.id.UUIDGenerator" />
    </id>

    <property name = "title" column = "title" type = "org.hibernate.type.TextType"/>
    <property name = "description" column = "description" type = "org.hibernate.type.TextType" />

    <set name = "questions" table = "category_questions" cascade = "all"  inverse = "true">
        <key column = "category_id" not-null = "true" />
        <one-to-many class = "cdd.model.Question"/> 
    </set>

    <join table = "category" >
        <key column = "category_id"/>
        <many-to-one name="category" column = "category_id" not-null = "true"/>
    </join>

</class>