-->
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: Tasble per subclass using discriminator problem...
PostPosted: Wed Feb 23, 2005 4:12 pm 
Newbie

Joined: Fri Jan 14, 2005 4:58 am
Posts: 10
I have tried following the example in the 3.0 documentation and fail to see what I have missed. All sugestions are appreciated!

Hibernate version: 3.0
Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping
package="org.hibernate.log">
<class name="LogData">
<id name="id" unsaved-value="-1">
<generator class="native"/>
</id>
<discriminator column="recordtype" type="string"/>
<property name="time" not-null="true"/>
<property name="sequenceNumber" not-null="true"/>
<many-to-one name="source" class="Source" not-null="true"/>
<many-to-one name="activity" class="JobRelatedActivity" not-null="false"/>
<property name="description" not-null="true"/>
<list name="arguments">
<key column="id"/>
<index column="arg" type="byte"/>
<element column="argument" type="string"/>
</list>
<subclass name="TracingData" discriminator-value="1">
<join table="tracingdata">
<property name="sourceClass"/>
<property name="sourceMethod"/>
<property name="threadId"/>
</join>
</subclass>
</class>
</hibernate-mapping>

Full stack trace of any exception that occurs:
org.hibernate.MappingException: Error reading resource: org/hibernate/log/LogData.hbm.xml
at org.hibernate.cfg.Configuration.addClass(Configuration.java:463)
at org.hibernate.log.HibernateSupport.<clinit>(HibernateSupport.java:16)
at org.hibernate.log.Main.createLogData(Main.java:21)
at org.hibernate.log.Main.main(Main.java:67)
Caused by: org.hibernate.MappingException: invalid mapping
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:391)
at org.hibernate.cfg.Configuration.addClass(Configuration.java:460)
... 3 more
Caused by: org.xml.sax.SAXParseException: Element type "join" 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:334)
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:390)
... 4 more
20:47:37,884 ERROR XMLHelper:57 - Error parsing XML: XML InputStream(23) Element type "join" must be declared.
20:47:37,894 ERROR XMLHelper:57 - Error parsing XML: XML InputStream(28) The content of element type "subclass" must match "(meta*,(property|many-to-one|one-to-one|component|dynamic-component|any|map|set|list|bag|idbag|array|primitive-array)*,subclass*)".
java.lang.NullPointerException
at org.hibernate.log.HibernateSupport.getSession(HibernateSupport.java:47)
at org.hibernate.log.Main.createLogData(Main.java:21)
at org.hibernate.log.Main.main(Main.java:67)



Top
 Profile  
 
 Post subject: Found the problem myself....
PostPosted: Thu Feb 24, 2005 9:06 am 
Newbie

Joined: Fri Jan 14, 2005 4:58 am
Posts: 10
Used the wrong version of the DTD.....


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 23, 2005 11:27 pm 
Newbie

Joined: Wed Mar 23, 2005 11:19 pm
Posts: 1
i am using the hibernate-mapping 3.0 .dtd
and also find this problem..
In hibernate's reference
Code:
<class name="Payment" table="PAYMENT">
    <id name="id" type="long" column="PAYMENT_ID">
        <generator class="native"/>
    </id>
    <discriminator column="PAYMENT_TYPE" type="string"/>
    <property name="amount" column="AMOUNT"/>
    ...
    <subclass name="CreditCardPayment" discriminator-value="CREDIT">
        <join table="CREDIT_PAYMENT">
            <property name="creditCardType" column="CCTYPE"/>
            ...
        </join>
    </subclass>
    <subclass name="CashPayment" discriminator-value="CASH">
        <join table="CASH_PAYMENT">
            ...
        </join>
    </subclass>
    <subclass name="ChequePayment" discriminator-value="CHEQUE">
        <join table="CHEQUE_PAYMENT" fetch="select">
            ...
        </join>
    </subclass>
</class>

is right?


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.