-->
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: [mapping files] adding attributes causes errors
PostPosted: Mon Dec 04, 2006 12:55 pm 
Newbie

Joined: Wed Oct 11, 2006 11:32 am
Posts: 18
Hello,

i have POJO which works fine with hibernate. It has a one-to-many association :

Code:
       <set name="filterCollection" table="VarReportFilter">
           <key column="VarReportSetupId"/>
           <one-to-many class="VarReportFilter" cascade="save-update,persist"/>
       </set>


When i create my session factory it works fine without the cascade attribute

Code:
SessionFactory factory = new Configuration().configure("config/hibernate.cfg.xml").buildSessionFactory();


When i add it here is what i get when creating the session factory :

Code:
Initial SessionFactory creation failed.org.hibernate.MappingException: Could not read mappings from resource: com/start/hibernate/test/VarReportSetup.hbm.xml
Exception in thread "main" java.lang.ExceptionInInitializerError
   at com.start.hibernate.test.util.HibernateUtil.<clinit>(HibernateUtil.java:19)
   at com.start.hibernate.test.api.ProfilingLocaleUserApi.main(ProfilingLocaleUserApi.java:26)
Caused by: org.hibernate.MappingException: Could not read mappings from resource: com/start/hibernate/test/VarReportSetup.hbm.xml
   at org.hibernate.cfg.Configuration.addResource(Configuration.java:485)
   at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1465)
   at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1433)
   at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1414)
   at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1390)
   at org.hibernate.cfg.Configuration.configure(Configuration.java:1310)
   at com.start.hibernate.test.util.HibernateUtil.<clinit>(HibernateUtil.java:13)
   ... 1 more
Caused by: org.hibernate.MappingException: invalid mapping
   at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:425)
   at org.hibernate.cfg.Configuration.addResource(Configuration.java:482)
   ... 7 more
Caused by: org.xml.sax.SAXParseException: Attribute "cascade" must be declared for element type "one-to-many".
   at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
   at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(Unknown Source)
   at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
   at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
   at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.addDTDDefaultAttrsAndValidate(Unknown Source)
   at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.handleStartElement(Unknown Source)
   at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.emptyElement(Unknown Source)
   at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
   at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
   at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
   at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
   at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
   at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
   at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
   at org.dom4j.io.SAXReader.read(SAXReader.java:465)
   at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:422)
   ... 8 more



Any ideas ?
Many thanks :D


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 04, 2006 1:07 pm 
Senior
Senior

Joined: Tue Aug 23, 2005 8:52 am
Posts: 181
The cascade attribute needs to be on the "set" mapping and not the "one-to-many". Refer to the DTD.


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.