This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes Hibernate: Executing stored procedure using hibernate Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate: Executing stored procedure using hibernate" Watch "Hibernate: Executing stored procedure using hibernate" New topic
Author

Hibernate: Executing stored procedure using hibernate

sachin Misurkar
Greenhorn

Joined: Jul 24, 2008
Posts: 5
Hi
I am trying to execute stored procedure using execute but it giving this Exception.

****************************************************
log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
Exception in thread "main" org.hibernate.MappingException: Error reading resource: Insurance.hbm.xml
at org.hibernate.cfg.Configuration.addResource(Configuration.java:447)
at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1381)
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java: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 com.test.SPExec.main(SPExec.java:24)
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)
... 7 more
Caused by: org.xml.sax.SAXParseException: Attribute "callable" must be declared for element type "sql-query".
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.addDTDDefaultAttrsAndValidate(Unknown Source)
at org.apache.xerces.impl.dtd.XMLDTDValidator.handleStartElement(Unknown Source)
at org.apache.xerces.impl.dtd.XMLDTDValidator.startElement(Unknown Source)
at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(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:334)
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:393)
... 8 more
*************************************************

I am using MySQL5

My hbm mapping file-

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated Aug 1, 2008 12:33:30 PM by Hibernate Tools 3.2.1.GA -->
<hibernate-mapping>
<class name="com.test.Insurance" table="insurance">
<id name="iid" type="java.lang.Integer">
<column name="iid" />
<generator class="identity" />
</id>
<property name="insuranceName" type="string">
<column name="insurance_name" length="45" not-null="true" />
</property>
<property name="investedAmount" type="int">
<column name="invested_amount" not-null="true" />
</property>
<loader query-ref="sp_select" />
</class>
<sql-query name="sp_select" callable="true">
<return alias="ins" class="com.test.Insurance">
<return-property name="iid" column="iid" />
<return-property name="insuranceName" column="insurance_name" />
<return-property name="investedAmount" column="invested_amount" />
</return>
{? =call sp_select()}
</sql-query>

</hibernate-mapping>

My Stored procedure-

DELIMITER $$

DROP PROCEDURE IF EXISTS `demo`.`sp_select` $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_select`()
BEGIN
update insurance set value="xxxx" where insurance_name='sachin';
END $$

DELIMITER ;



Please suggest me where i m missing...
Thanks in advance
-Sachin
v srinibas rao
Greenhorn

Joined: Feb 17, 2009
Posts: 1
just check hibernate-mapping dtd file in the hibernate jar ,do the dtd file contains the string callable ,i hope it is not there in the dtd file,plese take the lattest hibernate jar file ,then try to run,i hope this will resolve your problem
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Hibernate: Executing stored procedure using hibernate
 
Similar Threads
InvalidMappingException
Hibernate exception for one-to-one mapping
Session throwing NullPointerException
problem with hibernate mapping
Invalid Mapping Exception while inserting data through hibernate