Reputation: 61
I get an error; however, I can not figure out why I'm getting this error. The first class
element doesn't give any error however the second class
element gives the error. (NB: I have other mappings but it is a repeat of the same error so I didn't worry to put the entire file)
"The content of element type "class" must match
"(meta*,subselect?,cache?,synchronize*,comment?,tuplizer*,(id|composite-id),discriminator?,natural-id?,(version|timestamp)?,(property|many-to-one|one-to-one|component|dynamic-component|properties|any|map|set|list|bag|idbag|array|primitive-array),((join,subclass*)|joined-subclass*|union-subclass*),loader?,sql-insert?,sql-update?,sql-delete?,filter*,resultset*,(query|sql-query)*)"
Any help would be appreciated:
Code
<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>
Upvotes: 0
Views: 140
Reputation: 131
Place the join tag part after set
<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>
Upvotes: 2