-->
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.  [ 5 posts ] 
Author Message
 Post subject: invalid mapping The content of element type "class"
PostPosted: Wed Sep 14, 2005 5:13 pm 
Newbie

Joined: Mon Jul 11, 2005 8:34 am
Posts: 12
Hi everyone, I've searched all over for this error but I can't figure out what's going on! :( I've already double checked the database name, fields, types, package paths against the xml and classes and they all match. and I only get the error on one particular hbm.xml mapping file when it gets read. if I take it out of the hibernate.cfg.xml all the other tables/classes work fine. the error occurs when a factory is built the first time.

here's the xml that causes the problem
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
   "hibernate-mapping-2.0.dtd">
<hibernate-mapping>
   <class name="br.gov.embrapa.proju.po.AdvogadoPO" table="proju.ADVOGADO" >
      <id name="idAdvogado" unsaved-value="null" type="int">
         <column name="AdvogadoId" not-null="true" />
         <generator class="sequence">
            <param name="sequence">proju.ADVOGADO_SQ</param>
         </generator>
      </id>
      <id name="matricula" type="int">
         <column name="matrica" not-null="true"/>
         <generator class="native"/>
      </id>
      <property name="OAB" type="java.lang.String">
         <column name="OAB" length="10" not-null="true"/>
      </property>
      <property name="observacao" type="java.lang.String">
         <column name="observacao" length="4000" not-null="true"/>
      </property>
   
      <!--<many-to-one name="matricFunc" column="MATRICA" class="br.gov.embrapa.proju.po.EmpregadoPO"/>-->
      
   </class>
</hibernate-mapping>

note: I already tried taking the <many-to-one/> line out, same error :(

the error:
Code:
SEVERE: SessionFactory failed.
net.sf.hibernate.MappingException: Error reading resource: advogado.hbm.xml
   at net.sf.hibernate.cfg.Configuration.addResource(Configuration.java:339)
   at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.java:1018)
   at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.java:974)
   at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:902)
   at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:888)
   at br.gov.embrapa.corporativo.util.HibernateUtil.<clinit>(HibernateUtil.java:22)
   at br.gov.embrapa.corporativo.persistencia.PersistenceService.retrieveObjs(PersistenceService.java:118)
   at br.gov.embrapa.proju.negocio.TipoAcao.getTodosTiposAcoes(TipoAcao.java:56)
   at br.gov.embrapa.proju.action.TipoAcaoAction.execute(TipoAcaoAction.java:48)
   at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:421)
   at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:226)
   at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
   at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:397)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
   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: net.sf.hibernate.MappingException: invalid mapping
   at net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:287)
   at net.sf.hibernate.cfg.Configuration.addResource(Configuration.java:336)
   ... 38 more
Caused by: org.xml.sax.SAXParseException: The content of element type "class" must match "(meta*,(cache|jcs-cache)?,(id|composite-id),discriminator?,(version|timestamp)?,(property|many-to-one|one-to-one|component|dynamic-component|any|map|set|list|bag|idbag|array|primitive-array)*,(subclass*|joined-subclass*))".
   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)


Any suggestion would be much appreciated! Thanks in advance!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 14, 2005 6:14 pm 
Expert
Expert

Joined: Thu Dec 04, 2003 12:36 pm
Posts: 275
Location: Bielefeld, Germany
Two <id> elements?!
What are you trying to do?

Best regards
Sven

_________________
Please don't forget to give credit, if this posting helped to solve your problem.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 14, 2005 6:19 pm 
Expert
Expert

Joined: Thu Dec 04, 2003 12:36 pm
Posts: 275
Location: Bielefeld, Germany
Well, to be a bit more precise...
Looking at the DTD the <id> element may only be used once per <class> element.

Code:
<!ELEMENT class (
  meta*,
  (cache|jcs-cache)?,
  (id|composite-id),
  discriminator?,
  (version|timestamp)?,
  (property|many-to-one|one-to-one|component|dynamic-component|any|map|set|list|bag|idbag|array|primitive-array)*,
  ((subclass*)|(joined-subclass*))
)>


If you're trying to use a composite id use the corresponding <composite-id> element instead of the <id> element and re-read the documentation.
http://www.hibernate.org/hib_docs/refer ... ompositeid

Best regards
Sven

_________________
Please don't forget to give credit, if this posting helped to solve your problem.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 15, 2005 7:05 am 
Newbie

Joined: Mon Jul 11, 2005 8:34 am
Posts: 12
Thanks a million sven! I'll read the documentation right now. I heard once from someone that using composite-id isn't recommended. Is it true at all? If so, then what's the best way to deal with multiple primary keys on one table though xml so that you can relate it to other?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 15, 2005 7:09 am 
Expert
Expert

Joined: Thu Dec 04, 2003 12:36 pm
Posts: 275
Location: Bielefeld, Germany
Having the chance to choose your data model, use surrogate keys which is a best practice. If you're using a legacy database without any chance to change the data model, you can of course use composite ids in Hibernate.

Best regards
Sven

PS: You are allowed to rate my posting. ;)

_________________
Please don't forget to give credit, if this posting helped to solve your problem.


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