-->
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.  [ 13 posts ] 
Author Message
 Post subject: hbm2java does not process filter-def and filter elements?
PostPosted: Wed Jan 17, 2007 9:31 am 
Newbie

Joined: Wed Jan 17, 2007 9:24 am
Posts: 7
I added filter-def and filter elements to the hibernate mapping file. Now hbm2java complains. I am using Hibernate 3.1. Does anyone know about the issue and can suggest a work-around? Thanks for any pointers.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 17, 2007 9:51 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
complains how ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 17, 2007 10:21 am 
Newbie

Joined: Wed Jan 17, 2007 9:24 am
Posts: 7
Failed in building configuration when adding myclass.hbm.xml


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 17, 2007 10:58 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
yeees, but I can't help much when you just say "it complains" and "fails in building something"

...what about stacktraces, error messages and the files you actually hand to it ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 18, 2007 10:43 am 
Newbie

Joined: Wed Jan 17, 2007 9:24 am
Posts: 7
Below is the mapping file I have. Without the filter-def and filter element, hbm2java generates the java code. I am wondering if the hbm2java that comes with Hibernate 3.1 package may not support the filters? Thanks!


<?xml version="1.0" encoding="UTF-8"?>

<!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="myAppFilter">
<filter-param name="myAppFilterParam" type="java.lang.String"/>
</filter-def>

<class name="myClass" table="MY_TABLE" lazy="false">
<meta attribute="scope-field">protected</meta>
<cache usage="read-write"/>
<id name="id" column="MY_ID" type="java.lang.Long">
<generator class="sequence">
<param name="sequence">MYID_SEQ</param>
</generator>
</id>
<property name="appId" column="APP_ID" type="java.lang.String" length="24" not-null="true"/>
<filter name="myAppFilter" condition=":myAppFilterParam != APP_ID"/>
</class>

</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 18, 2007 10:44 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
could you *please* show the stacktrace and error message too.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 18, 2007 11:04 am 
Newbie

Joined: Wed Jan 17, 2007 9:24 am
Posts: 7
I just learned the -debug option. So here is the full stack trace, which seems to confirm my earlier guess - the filter-def and filter tag are not supported by the tool in the version we are using?

build.xml:176: Failed in building configuration when adding /software/src/ems/src/orm/ormModel/build/gen/mappings/AppPrivDetail.hbm.xml
at org.hibernate.tool.ant.ConfigurationTask.addFile(ConfigurationTask.java:145)
at org.hibernate.tool.ant.ConfigurationTask.addMappings(ConfigurationTask.java:123)
at org.hibernate.tool.ant.ConfigurationTask.doConfiguration(ConfigurationTask.java:109)
at org.hibernate.tool.ant.ConfigurationTask.getConfiguration(ConfigurationTask.java:55)
at org.hibernate.tool.ant.HibernateToolTask.getConfiguration(HibernateToolTask.java:179)
at org.hibernate.tool.ant.HibernateToolTask.getProperties(HibernateToolTask.java:195)
at org.hibernate.tool.ant.ExporterTask.configureExporter(ExporterTask.java:90)
at org.hibernate.tool.ant.Hbm2JavaExporterTask.configureExporter(Hbm2JavaExporterTask.java:34)
at org.hibernate.tool.ant.ExporterTask.execute(ExporterTask.java:38)
at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:143)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
at org.apache.tools.ant.Task.perform(Task.java:364)
at org.apache.tools.ant.Target.execute(Target.java:341)
at org.apache.tools.ant.Target.performTasks(Target.java:369)
at org.apache.tools.ant.Project.executeTarget(Project.java:1214)
at org.apache.tools.ant.Project.executeTargets(Project.java:1062)
at org.apache.tools.ant.Main.runBuild(Main.java:673)
at org.apache.tools.ant.Main.startAnt(Main.java:188)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:196)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:55)
Caused by: org.hibernate.MappingException: Could not read mapping document from file: /software/src/ems/src/orm/ormModel/build/gen/mappings/AppPrivDetail.hbm.xml
at org.hibernate.cfg.Configuration.addFile(Configuration.java:269)
at org.hibernate.tool.ant.ConfigurationTask.addFile(ConfigurationTask.java:140)
... 19 more
Caused by: org.hibernate.MappingException: invalid mapping
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:424)
at org.hibernate.cfg.Configuration.addFile(Configuration.java:266)
... 20 more
Caused by: org.xml.sax.SAXParseException: The content of element type "hibernate-mapping" must match "(meta*,typedef*,import*,(class|subclass|joined-subclass|union-subclass)*,resultset*,(query|sql-query)*,filter-def*,database-object*)".
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.dtd.XMLDTDValidator.handleEndElement(Unknown Source)
at org.apache.xerces.impl.dtd.XMLDTDValidator.endElement(Unknown Source)
at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.dom4j.io.SAXReader.read(SAXReader.java:465)
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:421)
... 21 more
--- Nested Exception ---
org.hibernate.MappingException: Could not read mapping document from file: /software/src/ems/src/orm/ormModel/build/gen/mappings/AppPrivDetail.hbm.xml
at org.hibernate.cfg.Configuration.addFile(Configuration.java:269)
at org.hibernate.tool.ant.ConfigurationTask.addFile(ConfigurationTask.java:140)
at org.hibernate.tool.ant.ConfigurationTask.addMappings(ConfigurationTask.java:123)
at org.hibernate.tool.ant.ConfigurationTask.doConfiguration(ConfigurationTask.java:109)
at org.hibernate.tool.ant.ConfigurationTask.getConfiguration(ConfigurationTask.java:55)
at org.hibernate.tool.ant.HibernateToolTask.getConfiguration(HibernateToolTask.java:179)
at org.hibernate.tool.ant.HibernateToolTask.getProperties(HibernateToolTask.java:195)
at org.hibernate.tool.ant.ExporterTask.configureExporter(ExporterTask.java:90)
at org.hibernate.tool.ant.Hbm2JavaExporterTask.configureExporter(Hbm2JavaExporterTask.java:34)
at org.hibernate.tool.ant.ExporterTask.execute(ExporterTask.java:38)
at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:143)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
at org.apache.tools.ant.Task.perform(Task.java:364)
at org.apache.tools.ant.Target.execute(Target.java:341)
at org.apache.tools.ant.Target.performTasks(Target.java:369)
at org.apache.tools.ant.Project.executeTarget(Project.java:1214)
at org.apache.tools.ant.Project.executeTargets(Project.java:1062)
at org.apache.tools.ant.Main.runBuild(Main.java:673)
at org.apache.tools.ant.Main.startAnt(Main.java:188)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:196)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:55)
Caused by: org.hibernate.MappingException: invalid mapping
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:424)
at org.hibernate.cfg.Configuration.addFile(Configuration.java:266)
... 20 more
Caused by: org.xml.sax.SAXParseException: The content of element type "hibernate-mapping" must match "(meta*,typedef*,import*,(class|subclass|joined-subclass|union-subclass)*,resultset*,(query|sql-query)*,filter-def*,database-object*)".
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.dtd.XMLDTDValidator.handleEndElement(Unknown Source)
at org.apache.xerces.impl.dtd.XMLDTDValidator.endElement(Unknown Source)
at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.dom4j.io.SAXReader.read(SAXReader.java:465)
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:421)
... 21 more


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 18, 2007 11:14 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
no it just shows that the syntax of your mapping file is incorrect. fix that and it should work.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 18, 2007 11:21 am 
Newbie

Joined: Wed Jan 17, 2007 9:24 am
Posts: 7
If you have found what I did wrong with the filter definition I added, can you please share it?

The new element I added under hibernate-mapping is filter-def as suggested by the error message. Is the tool sensitive with white spaces?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 18, 2007 11:29 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
read the error message ;)

it says that filter-def needs to come *after* class

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 18, 2007 11:34 am 
Newbie

Joined: Wed Jan 17, 2007 9:24 am
Posts: 7
Thanks for the help! I did not realize the order matters.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 18, 2007 11:54 am 
Newbie

Joined: Wed Jan 17, 2007 9:24 am
Posts: 7
One follow-up question:

The filter-def element defines the named filter. Intuitively, the filter-def should be defined first before the class that uses the defined filter? Am I missing anything else here?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 18, 2007 11:57 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
thats just how the dtd is.....

_________________
Max
Don't forget to rate


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