-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Error reading resource: com/jlc/hibernate/customer.hbm.xml
PostPosted: Fri Dec 19, 2014 1:24 am 
Newbie

Joined: Fri Dec 19, 2014 12:50 am
Posts: 4
Hii

I am getting this error when ever i a m trying to run my code,for the collection mapping using hibernate,pls tell me where should i change my code...


org.hibernate.MappingException: Error reading resource: com/jlc/hibernate/customer.hbm.xml
at org.hibernate.cfg.Configuration.addResource(Configuration.java:452)
at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1263)
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1235)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1217)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1184)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1112)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1098)
at com.jlc.hibernate.Client.main(Client.java:13)
Caused by: org.hibernate.MappingException: invalid mapping
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:399)
at org.hibernate.cfg.Configuration.addResource(Configuration.java:449)
... 7 more
Caused by: org.xml.sax.SAXParseException: Element type "List" must be declared.
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.dtd.XMLDTDValidator.handleStartElement(Unknown Source)
at org.apache.xerces.impl.dtd.XMLDTDValidator.startElement(Unknown Source)
at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.dom4j.io.SAXReader.read(SAXReader.java:465)
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:398)
... 8 more


customer.hbm.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >


<hibernate-mapping package="com.jlc.hibernate">
<class name="Customer" table="customer_table">

<id name="cid" column="cid" type="int">
<generator class="increment">
</generator>
</id>
<property name="cname" type="string"></property>
<List name="emails" table="emails_table">
<key column="cid"/>
<list-index column="index"></list-index>
<element column="emailId" type="string"/>
</List>

<set name="phones" table="phones_table">
<key column="cid"></key>
<element column="phoneno" type="string"/>
</set>

<map name="refs" table="refs_table">
<key column="cid"/>
<index column="rname" type="string"/>
<element column="rphone" type="string"/>
</map>

</class>
</hibernate-mapping>


client.java
package com.jlc.hibernate;

import org.hibernate.*;
import org.hibernate.cfg.*;
import java.util.*;

class Client
{
public static void main(String as[])
{
try{
Configuration cfg=new Configuration();
cfg=cfg.configure();
SessionFactory sf=cfg.buildSessionFactory();
Session s=sf.openSession();
Transaction tx=s.beginTransaction();
System.out.println("hiii sufiii");

//List ems=new ArrayList();

List<String> ems=new ArrayList<String>();
ems.add("a@gmail.com");
ems.add("b@gmail.com");

Set<String> phs=new HashSet<String>();
phs.add("2211");
phs.add("3322");

Map<String, String> refs=new HashMap<String, String>();
refs.put("r1", "11");
refs.put("r2", "22");

Customer c=new Customer();
s.save(c);
Customer cust=(Customer)s.load(Customer.class,"c");
System.out.println(cust.getCname());
System.out.println(cust.getEmails());
System.out.println(cust.getPhones());
System.out.println(cust.getRefs());
tx.commit();
}catch(Exception e)
{
e.printStackTrace();

}

}

}


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.