-->
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.  [ 2 posts ] 
Author Message
 Post subject: net.sf.hibernate.MappingException: invalid mapping
PostPosted: Tue Dec 07, 2004 8:22 pm 
Newbie

Joined: Sat Dec 04, 2004 10:23 pm
Posts: 13
Hibernate version: 2.1.6
I need to solve this quickly
i don't have time
please help me


I have following mapping files
User mapping file contains list of orders (one to many)
Order contians( many to one)
I am getting invalid mapping exception
I don't know where i am going wrong

mapping documents

UserData.hbm.xml


<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 1.1//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-1.1.dtd">

<hibernate-mapping
>
<class
name="UserData"
table="UserData"
>

<id
name="userID"
column="userID"
type="int"
>
<generator class="native">
<!--
To add non XDoclet generator parameters, create a file named
hibernate-generator-params-UserData.xml
containing the additional parameters and place it in your merge dir.
-->
</generator>
</id>

<property
name="addressData"
type="java.lang.String"
column="addressData"
/>

<property
name="cardNumber"
type="java.lang.String"
column="cardNumber"
/>

<property
name="cardType"
type="java.lang.String"
column="cardType"
/>

<property
name="expiryDate"
type="java.util.Date"
column="expiryDate"
/>

<!-- <property
name="orderData"
type="java.util.List"
column="orderData"
/>
-->

<list name="OrderData" role="OrderData" lazy="true" >
<key column="userID" />

<one-to-many class="OrderData" />
</list>

<property
name="password"
type="java.lang.String"
column="password"
/>

<property
name="userName"
type="java.lang.String"
column="userName"
/>

<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-UserData.xml
containing the additional properties and place it in your merge dir.
-->

</class>

</hibernate-mapping>


OrderData.hbm.xml


<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 1.1//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-1.1.dtd">

<hibernate-mapping
>
<class
name="OrderData"
table="OrderData"
>

<id
name="orderId"
column="OrderId"
type="int"
>
<generator class="native">
<!--
To add non XDoclet generator parameters, create a file named
hibernate-generator-params-OrderData.xml
containing the additional parameters and place it in your merge dir.
-->
</generator>
</id>

<property
name="billingAddress"
type="java.lang.String"
column="BillingAddress"
/>

<list name="BookData"
role="BookData"
table="BookData"
lazy="true"
cascade="none"
>

<key
column="orderId"
>
</key>

<one-to-many
class="BookData"
/>

</list>
<property
name="shippingAddress"
type="java.lang.String"
column="ShippingAddress"
/>

<many-to-one
name="UserData"
class="UserData"

column="userId"
not-null="true"

/> <!--
To add non XDoclet property mappings, create a file named
hibernate-properties-OrderData.xml
containing the additional properties and place it in your merge dir.
-->

</class>

</hibernate-mapping>




Error messages

[Caused by: net.sf.hibernate.MappingException: invalid mapping
at net.sf.hibernate.cfg.Configuration.addInputStream(Configurati

at net.sf.hibernate.cfg.Configuration.addResource(Configuration.

... 8 more
Caused by: org.xml.sax.SAXParseException: Attribute "name" must be d
element type "list".
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseExce
n Source)
at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Sour

at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown S

at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown S

at org.apache.xerces.impl.dtd.XMLDTDValidator.addDTDDefaultAttrs
Unknown Source)
at org.apache.xerces.impl.dtd.XMLDTDValidator.handleStartElement
rce)
at org.apache.xerces.impl.dtd.XMLDTDValidator.startElement(Unkno

at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElem
Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$Fragmen
atcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDoc
n Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown So

at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Sour

at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Sou

at org.dom4j.io.SAXReader.read(SAXReader.java:339)
at net.sf.hibernate.cfg.Configuration.addInputStream(Configurati

... 9 more
Java Result: 1


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 08, 2004 4:00 am 
Senior
Senior

Joined: Sat Jul 17, 2004 5:16 pm
Posts: 143
Read the exception closely, it tells you there. The attribute "name" is illegal for element "list". Here is the DTD to verify.

http://hibernate.sourceforge.net/hibern ... ng-2.0.dtd

Regards,
Chris


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

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.