Hi
I'm evaluating Hibernate and have a very simple Hibernate app consisting of a bean with 3 fields, a Sybase table with 3 fields, a utility class which creates a session factory and a main class which decides whether to list or insert data depending on the parameters passed to it.
I then try and modify .hbm.xml file to allow a stored procedure to be used - I've basically cut and pasted the code from 16.3.2 of the documentation and modified it to use my class and property names. I've haven't modified anything else, but now my app won't run. I keep getting loads of XML errors for my .hbx.xml file complaining of missiong atttributes which are NOT missing. Please see below for details.
Hibernate version: 3.1
Mapping documents:
<?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>
<class name="de.gloegl.road2hibernate.Event" table="COCKPIT_EVENTS_TEST">
<id name="id" column="uid" type="long">
<generator class="increment"/>
</id>
<property name="dt_datem" type="timestamp"/>
<property name="title" column="eventtitle"/>
</class>
<!-- When this code sql-query is removed, it all works well -->
<sql-query callable="true" name="Hibernate_Test">
<return alias="ce" class="de.gloegl.road2hibernate.Event">
<return-property name="id" column="uid"/>
<return-property name="dt_datem" column="dt_datem"/>
<return-property name="title" column="eventtitle"/>
</return>
{ ? = call Hibernate_Test() }
</sql-query>
</hibernate-mapping>
[Full stack trace of any exception that occurs:
INFO - Hibernate 3.0rc1
INFO - hibernate.properties not found
INFO - using CGLIB reflection optimizer
INFO - using JDK 1.4 java.sql.Timestamp handling
INFO - configuring from resource: /hibernate.cfg.xml
INFO - Configuration resource: /hibernate.cfg.xml
INFO - Mapping resource: de/gloegl/road2hibernate/Event.hbm.xml
ERROR - Error parsing XML: XML InputStream(17) Attribute "callable" must be decl
ared for element type "sql-query".
ERROR - Error parsing XML: XML InputStream(19) Element type "return-property" mu
st be declared.
ERROR - Error parsing XML: XML InputStream(20) Element type "return-property" mu
st be declared.
ERROR - Error parsing XML: XML InputStream(21) Element type "return-property" mu
st be declared.
ERROR - Error parsing XML: XML InputStream(22) The content of element type "retu
rn" must match "EMPTY".
Initial SessionFactory creation failed.org.hibernate.MappingException: Error rea
ding resource: de/gloegl/road2hibernate/Event.hbm.xml
Exception in thread "main" java.lang.ExceptionInInitializerError
at de.gloegl.road2hibernate.HibernateUtil.<clinit>(HibernateUtil.java:24
)
at de.gloegl.road2hibernate.EventManager.listEvents(EventManager.java:39
)
at de.gloegl.road2hibernate.EventManager.main(EventManager.java:22)
Caused by: org.hibernate.MappingException: Error reading resource: de/gloegl/roa
d2hibernate/Event.hbm.xml
at org.hibernate.cfg.Configuration.addResource(Configuration.java:447)
at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.jav
a:1381)
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.jav
a:1353)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1335)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1302)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1230)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1216)
at de.gloegl.road2hibernate.HibernateUtil.<clinit>(HibernateUtil.java:20
)
... 2 more
Caused by: org.hibernate.MappingException: invalid mapping
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:394
)
at org.hibernate.cfg.Configuration.addResource(Configuration.java:444)
... 9 more
Caused by: org.xml.sax.SAXParseException: Attribute "callable" must be declared
for element type "sql-query".
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAX
ParseException(Unknown Source)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(Unk
nown 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.addDTDDef
aultAttrsAndValidate(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.handleSta
rtElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.startElem
ent(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scan
StartElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImp
l$FragmentContentDispatcher.dispatch(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImp
l.scanDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(U
nknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(U
nknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown So
urce)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Un
known Source)
at org.dom4j.io.SAXReader.read(SAXReader.java:334)
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:393
)
... 10 more
Once I remove the <sql-query> fragment, the app works, but I need to get it working with Stored Procs. I've cut and pasted the <sql-query> fragment from the docs, so not sure where I'm going wrong. And I've tried placing the sql-query within the class tag and I get the same error.
Any help appreciated!
Cheers
Patrick.
|