-->
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.  [ 2 posts ] 
Author Message
 Post subject: subclass with a map
PostPosted: Mon Mar 16, 2009 4:41 pm 
Newbie

Joined: Tue Aug 21, 2007 10:35 am
Posts: 6
Hello I'm trying to use subclasses and a map (see the bold part of mapping), but it gives an error validating the XML (The content of element type "join" must match "(subselect?,comment?,key,(property|many-to-one|component|
dynamic-component|any)*,sql-insert?,sql-update?,sql-delete?)".)

And gives the follow exception, I know the XML is invalid, but I wanna know the right way to do it.

Code:
junit.framework.AssertionFailedError: Exception in constructor: test1 (org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext-athenasCore.xml]: Invocation of init method failed; nested exception is org.hibernate.InvalidMappingException: Could not parse mapping document from invalid mapping
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1337)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
   at java.security.AccessController.doPrivileged(Native Method)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
   at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
   at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:221)
   at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
   at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
   at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
   at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:423)
   at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:729)
   at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:381)
   at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
   at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
   at br.com.aedas.athenas.test.SpringHBNTSessionTestCase.loadContext(SpringHBNTSessionTestCase.java:43)
   at br.com.aedas.athenas.test.SpringHBNTSessionTestCase.<init>(SpringHBNTSessionTestCase.java:26)
   at br.com.aedas.athenas.test.SpringHBNTSessionTestCase.<init>(SpringHBNTSessionTestCase.java:33)
   at DocumentTypeDaoTest.<init>(DocumentTypeDaoTest.java:26)
   at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
   at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
   at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
   at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
   at junit.framework.TestSuite.createTest(TestSuite.java:131)
   at junit.framework.TestSuite.addTestMethod(TestSuite.java:114)
   at junit.framework.TestSuite.<init>(TestSuite.java:75)
   at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestLoader.getTest(JUnit3TestLoader.java:102)
   at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestLoader.loadTests(JUnit3TestLoader.java:59)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:445)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: org.hibernate.InvalidMappingException: Could not parse mapping document from invalid mapping
   at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:508)
   at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:638)
   at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1368)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1334)
   ... 31 more
Caused by: org.xml.sax.SAXParseException: The content of element type "join" must match "(subselect?,comment?,key,(property|many-to-one|component|dynamic-component|any)*,sql-insert?,sql-update?,sql-delete?)".
   at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:236)
   at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:172)
   at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:382)
   at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:316)
   at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.handleEndElement(XMLDTDValidator.java:2048)
   at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.endElement(XMLDTDValidator.java:932)
   at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanEndElement(XMLNSDocumentScannerImpl.java:719)
   at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1685)
   at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:368)
   at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:834)
   at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
   at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148)
   at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1242)
   at org.dom4j.io.SAXReader.read(SAXReader.java:465)
   at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:505)
   ... 35 more
)
   at junit.framework.Assert.fail(Assert.java:47)
   at junit.framework.TestSuite$1.runTest(TestSuite.java:263)
   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.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
   at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)




Hibernate version: 3.2.6

Mapping documents:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>
   <class name="br.com.aedas.eos.model.EosObject" table="eos_object" discriminator-value="BASE">
          <id name="id">
            <generator class="increment"/>
        </id>
        <discriminator column="eos_type" type="string" length="5" />
        <property name="name" length="50" not-null="true" unique="true"/>
        <many-to-one name="parent" column="parent_id" class="br.com.aedas.eos.model.EosObject"
                    index="ix_eos_object_parent_id" not-null="false" />
        <set name="tags" table="eos_object_tags" lazy="false">
            <key column="eos_object_id" />
            <element column="tag" type="string"/>
        </set>
        <map name="policyMap"
            table="policies">
          <key column="id"/>
          <map-key-many-to-many column="role_id" class="br.com.aedas.eos.model.Role" />
          <element column="policy" not-null="true"
                type="br.com.aedas.eos.dao.hibernate.enumHandle.PolicyToString" />
        </map>
       
     
Code:
   <subclass name="br.com.aedas.eos.model.LogicalDocument" discriminator-value="LGDOC">
           <join table="EOS_OBJECT_LGDOC">
               <key column="ID" />
               <property name="date" column="doc_date" not-null="true" />
               <property name="description" length="255" not-null="false" />
               <property name="date" column="doc_date" not-null="true" />
                <map name="detailMap" table="eos_document_lgdoc_detail">
                    <key column="id"/>
                    <map-key column="detail_id" type="string" length="50" />
                    <element column="value" not-null="true" type="string" length="50"/>
                </map>
               <many-to-one name="documentType" column="document_type_id"
                       class="br.com.aedas.eos.model.DocumentType"
                       not-null="false" />
               <many-to-one name="owner" column="owner_id" class="br.com.aedas.eos.model.User"
                    index="ix_eos_object_lgdoc_user_id" not-null="false" />
           </join>
        </subclass>
Code:
       
    </class>


Name and version of the database you are using: Apache Derby 10


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 17, 2009 6:22 am 
Expert
Expert

Joined: Fri Jan 30, 2009 1:47 am
Posts: 292
Location: Bangalore, India
why are you using a <join> tag? Did you mean <joined-subclass> instead?

<join> tag is for mapping a single class properties to columns of different table. Like you want the User class have properties from both tables USERS and ADDRESS. Its not for inheritance mapping. For inheritance mapping we use <joined-subclass>

_________________
Regards,
Litty Preeth


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