S
shaji
Hi,
I am facing tremendous difficulties in having Named Queries in
hibernate3.0.
Please help me out.
Following is a sample xml file in which I mentioned the named query
(NamedQuery.hbm.xml). It is mapped to the class
de.gloegl.road2hibernate.NamedQuery, and loading an instance is done
successfully.
<?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.NamedQuery"
table="AUDIT_DETAILS">
<id name="timestamp" column="si_timestamp" >
<generator class="increment"/>
</id>
<property name="company_id" column="company_id"/>
<property name="claim_id" column="claim_id"/>
<property name="operation" column="operation"/>
<property name="details" column="details"/>
</class>
<sql-query name="audit_display" callable="true" >
<return alias="audit" class="de.gloegl.road2hibernate.NamedQuery">
<return-discriminator column="company_id"/>
<return-property name="company_id" />
<return-property name="claim_id" />
<return-property name="timestamp" />
<return-property name="operation" />
<return-property name="details" />
</return>
SELECT audit.company_id AS company_id,
audit.claim_id AS claim_id,
audit.timestamp AS timestamp,
audit.operation AS operation,
audit.details AS details
FROM NamedQuery audit WHERE audit.details LIKE 'test%'
</sql-query>
</hibernate-mapping>
--------------------------
I am getting exceptions like this.
INFO - Mapping resource: de/gloegl/road2hibernate/NamedQuery.hbm.xml
ERROR - Error parsing XML: XML InputStream(17) Attribute "callable"
must be declared for element type "sql-query".
ERROR - Error parsing XML: XML InputStream(19) Element type
"return-discriminator" must be declared.
ERROR - Error parsing XML: XML InputStream(20) Element type
"return-property" must be declared.
ERROR - Error parsing XML: XML InputStream(21) Element type
"return-property" must be declared.
ERROR - Error parsing XML: XML InputStream(22) Element type
"return-property" must be declared.
ERROR - Error parsing XML: XML InputStream(23) Element type
"return-property" must be declared.
ERROR - Error parsing XML: XML InputStream(24) Element type
"return-property" must be declared.
ERROR - Error parsing XML: XML InputStream(25) The content of element
type "return" must match "EMPTY".
<snip>
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.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.startElement(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
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:334)
at
org.hibernate.cfg.Configuration.addInputStream(Configuration.java:393)
... 8 more
I am not getting any hint, what is happening here. As you see, I have
declated element types return-property. I have followed steps according
to the one example cited at hibernate.org.
Thanks,
Shaji.
I am facing tremendous difficulties in having Named Queries in
hibernate3.0.
Please help me out.
Following is a sample xml file in which I mentioned the named query
(NamedQuery.hbm.xml). It is mapped to the class
de.gloegl.road2hibernate.NamedQuery, and loading an instance is done
successfully.
<?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.NamedQuery"
table="AUDIT_DETAILS">
<id name="timestamp" column="si_timestamp" >
<generator class="increment"/>
</id>
<property name="company_id" column="company_id"/>
<property name="claim_id" column="claim_id"/>
<property name="operation" column="operation"/>
<property name="details" column="details"/>
</class>
<sql-query name="audit_display" callable="true" >
<return alias="audit" class="de.gloegl.road2hibernate.NamedQuery">
<return-discriminator column="company_id"/>
<return-property name="company_id" />
<return-property name="claim_id" />
<return-property name="timestamp" />
<return-property name="operation" />
<return-property name="details" />
</return>
SELECT audit.company_id AS company_id,
audit.claim_id AS claim_id,
audit.timestamp AS timestamp,
audit.operation AS operation,
audit.details AS details
FROM NamedQuery audit WHERE audit.details LIKE 'test%'
</sql-query>
</hibernate-mapping>
--------------------------
I am getting exceptions like this.
INFO - Mapping resource: de/gloegl/road2hibernate/NamedQuery.hbm.xml
ERROR - Error parsing XML: XML InputStream(17) Attribute "callable"
must be declared for element type "sql-query".
ERROR - Error parsing XML: XML InputStream(19) Element type
"return-discriminator" must be declared.
ERROR - Error parsing XML: XML InputStream(20) Element type
"return-property" must be declared.
ERROR - Error parsing XML: XML InputStream(21) Element type
"return-property" must be declared.
ERROR - Error parsing XML: XML InputStream(22) Element type
"return-property" must be declared.
ERROR - Error parsing XML: XML InputStream(23) Element type
"return-property" must be declared.
ERROR - Error parsing XML: XML InputStream(24) Element type
"return-property" must be declared.
ERROR - Error parsing XML: XML InputStream(25) The content of element
type "return" must match "EMPTY".
<snip>
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.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.startElement(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
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:334)
at
org.hibernate.cfg.Configuration.addInputStream(Configuration.java:393)
... 8 more
I am not getting any hint, what is happening here. As you see, I have
declated element types return-property. I have followed steps according
to the one example cited at hibernate.org.
Thanks,
Shaji.