java - Hibernate Error: org.hibernate.InvalidMappingException: Could not parse mapping document from resource -


when run project, occurs exception below. before add view table in hibernate, everyting got include blame.hbm.xml , others. , read data database. exception occurs in showorderdaoimpl.java @ sentence: session=hibernatesessionfactory.getsession();

my exception

    org.hibernate.invalidmappingexception: not parse mapping document resource pojo/blame.hbm.xml     @ org.hibernate.cfg.configuration$metadatasourcequeue.processhbmxml(configuration.java:3415)     @ org.hibernate.cfg.configuration$metadatasourcequeue.processhbmxmlqueue(configuration.java:3404)     @ org.hibernate.cfg.configuration$metadatasourcequeue.processmetadata(configuration.java:3392)     @ org.hibernate.cfg.configuration.secondpasscompile(configuration.java:1341)     @ org.hibernate.cfg.configuration.buildsessionfactory(configuration.java:1737)     @ session.factory.hibernatesessionfactory.rebuildsessionfactory(hibernatesessionfactory.java:75)     @ session.factory.hibernatesessionfactory.getsession(hibernatesessionfactory.java:57)     @ dao.impl.showorderdaoimpl.querytradesbybid(showorderdaoimpl.java:24)     @ test.testhibernate.main(testhibernate.java:45) caused by: org.hibernate.duplicatemappingexception: duplicate class/entity mapping pojo.blame ok     @ org.hibernate.cfg.configuration$mappingsimpl.addclass(configuration.java:2580)     @ org.hibernate.cfg.hbmbinder.bindroot(hbmbinder.java:174)     @ org.hibernate.cfg.configuration$metadatasourcequeue.processhbmxml(configuration.java:3412)     ... 8 more java.lang.nullpointerexception     @ dao.impl.showorderdaoimpl.querytradesbybid(showorderdaoimpl.java:25)     @ test.testhibernate.main(testhibernate.java:45) 

my hibernate.cfg.xml file

<?xml version="1.0" encoding="utf-8"?> <!doctype hibernate-configuration public "-//hibernate/hibernate configuration dtd 3.0//en"                                          "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> <hibernate-configuration>  <session-factory>   <property name="hibernate.connection.driver_class">com.mysql.jdbc.driver</property>   <property name="hibernate.connection.password">root</property>   <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/disputesystem</property>   <property name="hibernate.connection.username">root</property>   <property name="hibernate.dialect">org.hibernate.dialect.mysqldialect</property>   <property name="hibernate.show_sql">true</property>   <mapping resource="pojo/blame.hbm.xml"/>   <mapping resource="pojo/buyer.hbm.xml"/>   <mapping resource="pojo/dispute.hbm.xml"/>   <mapping resource="pojo/evidence.hbm.xml"/>   <mapping resource="pojo/goods.hbm.xml"/>   <mapping resource="pojo/message.hbm.xml"/>   <mapping resource="pojo/record.hbm.xml"/>   <mapping resource="pojo/seller.hbm.xml"/>   <mapping resource="pojo/staff.hbm.xml"/>   <mapping resource="pojo/trade.hbm.xml"/>   <mapping resource="pojo/fund.hbm.xml"/>   <mapping resource="pojo/showorderbybid.hbm.xml"/>  </session-factory> </hibernate-configuration> 

my showorderdaoimpl.java file

package dao.impl;  import java.util.arraylist; import java.util.date; import java.util.iterator; import java.util.list;  import org.hibernate.query; import org.hibernate.session; import org.hibernate.transaction;  import pojo.showorderbybid; import session.factory.hibernatesessionfactory; import dao.intf.showorderdao;  public class showorderdaoimpl implements showorderdao{      @override     public list<showorderbybid> querytradesbybid(string bid) throws exception {         session session=null;         transaction transaction=null;         list<showorderbybid> orders=new arraylist<showorderbybid>();         try {             session=hibernatesessionfactory.getsession();             transaction=session.begintransaction();             query query=session.createquery("from showorderbybid bid=?");             query.setparameter(0, bid);             orders=(list<showorderbybid>)query.list();             list countview = new arraylist();              iterator = orders.iterator();              while (it.hasnext()) {                 object[] = (object[]) it.next();                  showorderbybid countviewid = new showorderbybid();                  countviewid.setamount((integer) all[0]);                  countviewid.setbid((string) all[1]);                  countviewid.setdetail((string) all[2]);                  countviewid.setgid((string)all[3]);                  countviewid.setgname((string)all[4]);                 countviewid.setlogistics((string)all[5]);                 countviewid.setsid((string)all[6]);                 countviewid.setsname((string)all[7]);                 countviewid.setstatus((string)all[8]);                 countviewid.settid((string)all[9]);                 countviewid.settotalmoney((integer) all[10]);                 countviewid.settradetime((date)all[11]);                 orders.add(countviewid);               }           } catch (exception e) {             e.printstacktrace();          }finally{             hibernatesessionfactory.closesession();         }         return orders;     }  } 

my blame.hbm.xml file

    <?xml version="1.0"?> <!doctype hibernate-mapping public "-//hibernate/hibernate mapping dtd 3.0//en" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <!-- generated 2013-4-19 23:02:05 hibernate tools 3.4.0.cr1 --> <hibernate-mapping>     <class name="pojo.blame" table="blame" catalog="disputesystem">         <id name="id" type="java.lang.integer">             <column name="id" />             <generator class="identity" />         </id>         <many-to-one name="dispute" class="pojo.dispute" fetch="select">             <column name="disputeid" length="20" not-null="true" />         </many-to-one>         <property name="blametime" type="timestamp">             <column name="blametime" length="19" not-null="true" />         </property>         <property name="content" type="string">             <column name="content" length="1000" />         </property>     </class> </hibernate-mapping> 

looks there mapping pojo.blame. might had copy/paste mistake:

<class name="pojo.blame" 

in hbm file.

this

caused by: org.hibernate.duplicatemappingexception: duplicate class/entity mapping pojo.blame 

states when reached hbm file has definition class named pojo.blame.

looks in of files:

<mapping resource="pojo/blame.hbm.xml"/> <mapping resource="pojo/buyer.hbm.xml"/> <mapping resource="pojo/dispute.hbm.xml"/> <mapping resource="pojo/evidence.hbm.xml"/> <mapping resource="pojo/goods.hbm.xml"/> <mapping resource="pojo/message.hbm.xml"/> <mapping resource="pojo/record.hbm.xml"/> <mapping resource="pojo/seller.hbm.xml"/> <mapping resource="pojo/staff.hbm.xml"/> <mapping resource="pojo/trade.hbm.xml"/> <mapping resource="pojo/fund.hbm.xml"/> <mapping resource="pojo/showorderbybid.hbm.xml"/> 

is misplaced <class name="pojo.blame"


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -