Akash
Akash

Reputation: 29

The content of element type "id" must match "(meta*,column*,type?,generator?)")

I am getting below error in my hibernate class. The content of element type "id" must match "(meta*,column*,type?,generator?)"

Mapping class:

<class name="com.subex.models.Issues" table="ISSUES">

  <id name="id" type="integer" column="id" >
     <generator class="native"/>
     <param name="sequence">ISSUES_Seq</param>
  </id>

     <property name="brief" type="string" column="brief"/>
    <property name="description" type="string" column="description"/>
    <property name="module" type="string" column="module"/>
    <property name="version" type="string" column="version"/>
    <property name="site" type="string" column="site"/>
    <property name="posted_by" type="string" column="posted_by"/>
</class>

Please assist.

Upvotes: 2

Views: 3978

Answers (3)

amol khedkar
amol khedkar

Reputation: 141

The issue is in the xml tags not being properly formed here.

Here in your xml the param tag in not inside the generator tag.

<id name="id" type="integer" column="id" >
     <generator class="native"/>
     <param name="sequence">ISSUES_Seq</param>
  </id>

The proper way of doing it is :

<id name="id" type="integer" column="id" >
     <generator class="native">
          <param name="sequence">ISSUES_Seq</param>
     <generator>
</id>

Upvotes: 0

Balaji Reddy
Balaji Reddy

Reputation: 5700

<id name="id" type="integer" column="id" >
   <generator class="native"/>                <!-- 1 -->
   <param name="sequence">ISSUES_Seq</param>  <!-- 2 -->
</id>

Please remove the second line and check. It looks like You have used two ID generation strategies for single bean/entity (if i'm not wrong)

Upvotes: 2

ben75
ben75

Reputation: 28706

<param> is an inner element of generator, so you must do this:

<id name="id" type="integer" column="id" >
 <generator class="native">
     <param name="sequence">ISSUES_Seq</param>
 <generator>
</id>

Or better, since you use a sequence:

<id name="id" type="integer" column="id" >
 <generator class="sequence">
     <param name="sequence">ISSUES_Seq</param>
 <generator>
</id>

Upvotes: 0

Related Questions