• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem using Oracle stored procedure with Hibernate

 
Oliver Stagg
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'm new to Hibernate and was hoping someone could explain what I'm doing wrong here.

I have a stored procedure that I want to execute from Hibernate which I've defined in a named query.

Code as follows:

hibernate.cfg.xml



.hbm.xml file



Stored procedure:



AssetSettlementInfo.java:



Executing Code:


My .cfg.xml files lives in the root of my classpath and my hbm,xml files lives in the same folder as its corresponding class file.

When I try to invoke my getStatus() method I get the following stack trace:


Can someone try to explain what I�m doing wrong here?

Further to this I suspect I�m also calling the stored procedure incorrectly.

I�ve followed these two good examples of working with stored procedures and Hibernate
http://www.hibernate.org/hib_docs/v3/reference/en/html/querysql.html#sp_query
http://www.coderanch.com/t/216142/ORM/java/Executing-stored-procedures-hibernate

Am I correctly passing my bind parameter to the stored proc?

I�m doing it like this:


My stored proc does a join across two tables. Do I need to define two Java objects that map to each database table, or do I only need to define one object that matches the columns in my ref cursor returned by the stored proc?

Many thanks
Oliver
 
Edvins Reisons
Ranch Hand
Posts: 364
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Unknown entity" normally means just that: that Hibernate does not recognize the class as a mapped entity, has not seen its mapping file, etc.
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You've got the mapping configured in the config file, so it looks good.

Could you do a small test code and see if ActualSpecie.hbm.xml is being picked up, or if that generates the same error?

Maybe those files are just in the wrong place, or it's reading a different cfg file?

-Cameron McKenzie
 
Corey McGlone
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just did something similar, but I noticed a couple differences. In the mapping file, I included the field mappings, like this:



Then I have an additional hbm.xml file for the stored procedure that looks like this:



You may need to add an id field to your AssetSettlementInfo class for that to work.

How did I get to this, you ask? I have no idea. I hacked at it for quite some time until I got something to function. Now I'm afraid to breathe on it. Nonetheless, it does seem to be working well for me, now.

Hopefully, you'll find this helps.
[ July 24, 2008: Message edited by: Corey McGlone ]
 
Vijay Kumar Chaudhary
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
was this problem ever resolved?

did you face any error like Unable to instantiate default tuplizer
Corey McGlone wrote:I just did something similar, but I noticed a couple differences. In the mapping file, I included the field mappings, like this:



Then I have an additional hbm.xml file for the stored procedure that looks like this:



You may need to add an id field to your AssetSettlementInfo class for that to work.

How did I get to this, you ask? I have no idea. I hacked at it for quite some time until I got something to function. Now I'm afraid to breathe on it. Nonetheless, it does seem to be working well for me, now.

Hopefully, you'll find this helps.
[ July 24, 2008: Message edited by: Corey McGlone ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic