-->
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: Mapping <subclass> element into <component>
PostPosted: Mon Feb 28, 2005 10:51 am 
Newbie

Joined: Tue Aug 03, 2004 10:31 am
Posts: 7
Quote:
My question is: Can I map <subclass> element into <component> element?? 'cause the code below don´t compile, and I don't know why.
If there is other error plese notify me!!
Thank you, Gervasio. (Sorry by me english, I speak spanish...)


Hibernate version: 2.1.8

Mapping documents:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
   "-//Hibernate/Hibernate Mapping DTD//EN"
   "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
   <class name="modelo.Reserva" table="reservas">
        <id name="idReserva" column="idReserva" type="long">
              <generator class="increment"/>
        </id>
        <property name="fecha" type="date"/>      
        <many-to-one name="base" cascade="none" column="idBase" foreign-key="FK_BASE_RESERVA" not-null="true"/>
        <component name="formaPago" class="modelo.PagoReserva">
                <property name="precioTotal"/>
   <subclass name="modelo.PagoConTarjeta" discriminator-value="PT">
                <property name="valorReserva"/>
   <property name="nroTarjeta"/>
   <many-to-one name="marcaTarjeta" cascade="none" column="idMarcaTarjeta" foreign-key="FK_MARCAT_RESERVA" not-null="true"/>
   </subclass>
   <subclass name="modelo.PagoConPuntos" discriminator-value="PP">
   </subclass> 
        </component>
   </class>
</hibernate-mapping> 



Code between sessionFactory.openSession() and session.close():
No code, don´t map


Full stack trace of any exception that occurs:
INFO: Mapping resource: modelo/Reserva.hbm.xml
28-feb-2005 10:57:13 net.sf.hibernate.util.XMLHelper$ErrorLogger error
GRAVE: Error parsing XML: XML InputStream(24) The content of element type "component" must match "(meta*,parent?,(property|many-to-one|one-to-one|component|dynamic-component|any|map|set|list|bag|array|primitive-array)*)".
net.sf.hibernate.MappingException: Error reading resource: modelo/Reserva.hbm.xml
at net.sf.hibernate.cfg.Configuration.addClass(Configuration.java:358)
at conexion.Conexion.main(Conexion.java:20)
Caused by: net.sf.hibernate.MappingException: invalid mapping
at net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:288)
at net.sf.hibernate.cfg.Configuration.addClass(Configuration.java:355)
... 1 more
Caused by: org.xml.sax.SAXParseException: The content of element type "component" must match "(meta*,parent?,(property|many-to-one|one-to-one|component|dynamic-component|any|map|set|list|bag|array|primitive-array)*)".
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.DTDConfiguration.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:339)
at net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:287)
... 2 more


Name and version of the database you are using: My SQL 4.1.9

The generated SQL (show_sql=true): --------

Debug level Hibernate log excerpt: ?????


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 28, 2005 11:07 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
No way. Use a real associated entity.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 28, 2005 11:26 am 
Newbie

Joined: Tue Aug 03, 2004 10:31 am
Posts: 7
Ok, than you!!


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.