Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate beginner

 
Sharmistha Sarkar
Ranch Hand
Posts: 50
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I am trying to retrive data from MySql database using hibernate and getting an error in ..hbm.xml 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*,fetch-profile*,resultset*,(query|sql-query)*)"."

HibernatePoJo.hbm.xml:


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping SYSTEM " http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.cardinal.hibernate">
<class name="HibernatePoJo" table="Person">
<discriminator column="AGE" type="int" />
<discriminator column="name" type="string"/>
<discriminator column="ExamNo" type="int" />
</class>
</hibernate-mapping>


POJO class name:HibernatePoJo.java
MySql Table name: Person

I haven't specify <id>...</id> because in my database I didnt set any column as primary. Can anyone tell me why it is throwing error in the <class name ..>?
 
Ephraim Seoke
Greenhorn
Posts: 3
Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Map your HibernatePojo.hbm.xml to the Hibernate.cfg.xml configuration file:

<Mapping resource="Hibernate.hbm.xml"/>
</hibernate-mapping>
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic