Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Problem using Oracle stored procedure with Hibernate

 
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
https://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
 
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.
 
author and cow tipper
Posts: 5000
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
 
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 ]
 
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 ]

 
Men call me Jim. Women look past me to this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic