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 attributeCode:
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