Hi all,
How do I use a filter in the mapping mapping file??? I took the syntax directly off the Hibernate ref guide and I believe I'm using the correct DTD... But still I get an exception... If I remove the filter usage, all is ok...
Hibernate version:
3.1
Mapping documents:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<filter-def name="activeSession">
</filter-def>
<class name="test.Cls" table="CLS">
<id name="id" column="CLS_ID">
<generator class="native"/>
</id>
<map name="sess" cascade="all-delete-orphan" inverse="true">
<key column="CLS_ID" not-null="true"/>
<map-key formula="name" type="string"/>
<one-to-many class="test.Session"/>
<filter name="activeSession" condition="endtime is null"/>
</map>
</class>
</hibernate-mapping>
Name and version of the database you are using:
HSQL DB 1.8.0.4
Full stack trace of any exception that occurs:
12:07:36,265 ERROR XMLHelper:61 - Error parsing XML: XML InputStream(11) Element "hibernate-mapping" does not allow "class" here.
Initial SessionFactory creation failed.org.hibernate.MappingException: Could not read mappings from resource: test/Cls.hbm.xml
java.lang.ExceptionInInitializerError
at test.HibUtil.<clinit>(HibUtil.java:29)
at test.Main.main(Main.java:48)
Caused by: org.hibernate.MappingException: Could not read mappings from resource: test/Cls.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 org.hibernate.cfg.Configuration.configure(Configuration.java:1296)
at test.HibUtil.<clinit>(HibUtil.java:25)
... 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)
... 8 more
Caused by: org.xml.sax.SAXParseException: Element "hibernate-mapping" does not allow "class" here.
at org.apache.crimson.parser.Parser2.error(Parser2.java:3354)
at org.apache.crimson.parser.ValidatingParser$ChildrenValidator.consume(ValidatingParser.java:349)
at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1497)
at org.apache.crimson.parser.Parser2.content(Parser2.java:1963)
at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1691)
at org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:667)
at org.apache.crimson.parser.Parser2.parse(Parser2.java:337)
at org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:448)
at org.dom4j.io.SAXReader.read(SAXReader.java:465)
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:422)
... 9 more