-->
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.  [ 1 post ] 
Author Message
 Post subject: It says cascade is required ... but the DTD doesn't
PostPosted: Mon May 02, 2005 8:24 am 
Newbie

Joined: Wed Dec 08, 2004 5:59 pm
Posts: 3
Location: Detroit, MI
I've been trying to work out some cascading issues with my application and have run into a problem. The problem is that I have a composite-id on my ThingAddress table that is comprised of two columns - both of which are foreign keys. I'd like to apply cascade="all" to one of the columns and cascade="none" to the other.

Now, when I do so and run my JUnit test, it tells me

Code:
2005-05-02 07:57:48,376 ERROR [main] util.XMLHelper$ErrorLogger (XMLHelper.java:48) - Error parsing XML: XML InputStream(11) Attribute "cascade" must be declared for element type "key-many-to-one".

I can only assume that this is a typo and that it really wants to say "cascade must not be declared" because in the DTD I don't see a reference to cascade for the composite-id entity.

I'd really appreciate:

a) To know if the error message is innacurate
b) To know how I can apply cascade attributes to the objects in this mapping. It's a legacy schema, so I can't do anything to the table. Can I map it in a different way? Can I reflect the same columns both in the composite-id as well as in another attribute? Can I apply some formula?

Thanks in advance!

Joe




Hibernate version: 2.1.8
Mapping documents:

Code:
<hibernate-mapping>
    <class name="com.dom.thing.ThingAddress" table="SOMETABLE" dynamic-update="false" dynamic-insert="false" select-before-update="false" optimistic-lock="version">

        <composite-id unsaved-value="any">
            <key-many-to-one name="thing" class="com.dom.thing.Thing" column="THI_SK_SEQ" cascade="none" />
            <key-many-to-one name="thing2" class="com.dom.thing.Thing2" column="THIADD_SK_SEQ" cascade="all" />
        </composite-id>

            ...

    </class>
</hibernate-mapping>



Full stack trace of any exception that occurs:

Code:
2005-05-02 07:57:48,376 ERROR [main] util.XMLHelper$ErrorLogger (XMLHelper.java:48) - Error parsing XML: XML InputStream(11) Attribute "cascade" must be declared for element type "key-many-to-one".
2005-05-02 07:57:48,391 ERROR [main] util.XMLHelper$ErrorLogger (XMLHelper.java:48) - Error parsing XML: XML InputStream(12) Attribute "cascade" must be declared for element type "key-many-to-one".
2005-05-02 07:57:48,407 ERROR [main] persistence.HibernateUtil (HibernateUtil.java:146) - Building SessionFactory failed.
net.sf.hibernate.MappingException: Error reading resource: com/domain/thing/ThingAddress.hbm.xml
    at net.sf.hibernate.cfg.Configuration.addResource(Configuration.java:340)
    at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.java:1027)
    at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.java:983)
    at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:911)
    at com.fsb.framework.persistence.HibernateUtil.<clinit>(HibernateUtil.java:74)
    at com.fsb.domain.thing.ThingAddressDAOTest.testInsertAndDelete(ThingAddressDAOTest.java:77)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:324)
    at junit.framework.TestCase.runTest(TestCase.java:154)
    at junit.framework.TestCase.runBare(TestCase.java:127)
    at junit.framework.TestResult$1.protect(TestResult.java:106)
    at junit.framework.TestResult.runProtected(TestResult.java:124)
    at junit.framework.TestResult.run(TestResult.java:109)
    at junit.framework.TestCase.run(TestCase.java:118)
    at junit.framework.TestSuite.runTest(TestSuite.java:208)
    at junit.framework.TestSuite.run(TestSuite.java:203)
    at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:325)
    at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:536)
Caused by: net.sf.hibernate.MappingException: invalid mapping
    at net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:288)
    at net.sf.hibernate.cfg.Configuration.addResource(Configuration.java:337)
    ... 19 more
Caused by: org.xml.sax.SAXParseException: Attribute "cascade" must be declared for element type "key-many-to-one".
    at weblogic.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:232)
    at weblogic.apache.xerces.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:173)
    at weblogic.apache.xerces.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:371)
    at weblogic.apache.xerces.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:305)
    at weblogic.apache.xerces.impl.dtd.XMLDTDValidator.addDTDDefaultAttrsAndValidate(XMLDTDValidator.java:1192)
    at weblogic.apache.xerces.impl.dtd.XMLDTDValidator.handleStartElement(XMLDTDValidator.java:1844)
    at weblogic.apache.xerces.impl.dtd.XMLDTDValidator.emptyElement(XMLDTDValidator.java:745)
    at weblogic.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(XMLDocumentFragmentScannerImpl.java:747)
    at weblogic.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1477)
    at weblogic.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:329)
    at weblogic.apache.xerces.parsers.DTDConfiguration.parse(DTDConfiguration.java:525)
    at weblogic.apache.xerces.parsers.DTDConfiguration.parse(DTDConfiguration.java:581)
    at weblogic.apache.xerces.parsers.XMLParser.parse(XMLParser.java:152)
    at weblogic.apache.xerces.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1175)
    at weblogic.xml.jaxp.WebLogicXMLReader.parse(WebLogicXMLReader.java:135)
    at weblogic.xml.jaxp.RegistryXMLReader.parse(RegistryXMLReader.java:138)
    at org.dom4j.io.SAXReader.read(SAXReader.java:339)
    at net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:287)
    ... 20 more


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

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.