-->
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.  [ 3 posts ] 
Author Message
 Post subject: Please help me out of these error....
PostPosted: Tue Apr 17, 2007 2:41 am 
Newbie

Joined: Tue Apr 10, 2007 1:08 am
Posts: 2
Hi All,

Hi am created two tables in DB using my sql... I mapped them using on-to-one mapping. One key is Primary key in one table and the same is foregine key in the other.


Here is the code:

Configuration XML :

<?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.url">jdbc:mysql://localhost/girish</property>

<property name="hibernate.connection.username">root</property>

<property name="hibernate.connection.password">cts</property>

<property name="hibernate.connection.pool_size">10</property>

<property name="show_sql">true</property>

<property name="dialect">org.hibernate.dialect.MySQLDialect</property>

<property name="hibernate.hbm2ddl.auto">update</property>

<!-- Mapping files -->

<mapping resource="com\map.hbm.xml"/></session-factory>

</hibernate-configuration>


Mapping 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">

<hibernate-mapping>
<class name="com.CustomerInformation" table="CustomerInformation">
<id name="purchaseOrderNumber" type="integer" column="PurchaseOrderNumber">
<generator class="native"/>
</id>
<property name="companyName" column="CompanyName"/>
<property name="address" column="Address"/>
<property name="contactPerson" column="ContactPerson"/>
<property name="contactNumber" column="ContactNumber"/>
<property name="deliveryOrderNumber" column="DeliveryOrderNUmber"/>
<property name="invoiceNumber" column="InvoiceNumber"/>
<one-to-one name="purchaseOrderNumber" class="com.ProductInformation"/>
</class>
<class name="com.ProductInformation" table="ProductInformation">

<id name="purchaseOrderNumber" type="integer" column="PurchaseOrderNumber">
<generator class="foreign"/>
<param name="property">purchaseOrderNumber</param>
</id>
<property name="typeOfMaterial" column="TypeOfMaterial"/>
<property name="thicknessOfMaterial" column="ThicknessOfMaterial"/>
<property name="colourOfMaterial" column="ColourOfMaterial"/>
<property name="productType" column="ProductType"/>
<property name="productSize" column="ProductSize"/>
<property name="quantity" column="Quantity"/>
<one-to-one name="purchaseOrderNumber" class="com.CustomerInformation" constrained="true"/>
</class>
</hibernate-mapping>

But i am getting the error :

1. Caused by: org.hibernate.InvalidMappingException:[b] Could not parse mapping document from invalid mapping[/b]

2. Caused by: org.xml.sax.SAXParseException: [b]The content of element type "id" must match "(meta*,column*,type?,generator?)".[/b]


Here is the stack trace :::


org.hibernate.InvalidMappingException: Could not parse mapping document from resource com\map.hbm.xml
at org.hibernate.cfg.Configuration.addResource(Configuration.java:569)
at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1587)
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1555)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1534)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1508)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1428)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1414)
at com.PurchaseOrderSubmit.doPost(PurchaseOrderSubmit.java:28)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Thread.java:534)
Caused by: org.hibernate.InvalidMappingException: Could not parse mapping document from invalid mapping
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:502)
at org.hibernate.cfg.Configuration.addResource(Configuration.java:566)
... 33 more
Caused by: org.xml.sax.SAXParseException: The content of element type "id" must match "(meta*,column*,type?,generator?)".
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.handleEndElement(Unknown Source)
at org.apache.xerces.impl.dtd.XMLDTDValidator.endElement(Unknown Source)
at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(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:499)
... 34 more



Please reply to me...

Thanks in Advance....


Regards,
Girish.K


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 17, 2007 8:43 am 
Regular
Regular

Joined: Thu Dec 22, 2005 7:47 am
Posts: 62
Location: Czech Republic
you have an error in your mapping.

1. make sure what version of hibernate are you using

2. make sure the classpath (for building and for running) contains the same hibernate.jar (so it contains also the same DTD mapping document)

3. see that DTD document for allowed subelements/attributes of the "id" element. (mine from hibernate-3.2.2 forbids the usage of "param" element inside id -- see http://www.hibernate.org/hib_docs/reference/en/html/mapping.html#mapping-declaration-onetoone for an example -- put the param element inside the "generator" -- you have closed the "generator" element.)

regards, m.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 17, 2007 8:47 am 
Newbie

Joined: Thu Mar 29, 2007 7:03 am
Posts: 9
Location: Delhi
In second mapping

When you are using foreign generator you r passing parameter to that but your generator tag is closed. You have to close generator tag after param.

_________________
Jini


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.