Non-Entity Related Stored Procedures in Hibernate

W

wls

I'm using Hibernate to programmatically generate my database. That
said, I'm an annotation junkie, and basically have one very sparse
hibernate.cfg.xml to connect to my datasource, which happens to be
Postgres.

I need to be able to insert a stored procedure into the database and
then invoke it; the procedure has nothing to do with any @Entity
objects. And, while I can call SQL directly with
session.createQuery() easily enough, the real question is can I
somehow bundle the stored procedure with the app?

What I'd like to see is that there's a way I can say in my
hibernate.cfg.xml file something like:
<stored-procedure name="blah">
CREATE OR REPLACE FUNCTION someStoredProc(param character varying)
RETURNS...
...
</stored-procedure>

And, when I build the database, it gets added automagically, just as
my tables do.

And, ever hopeful, that I can then do session.getNamedQuery("blah")
and execute it, having it return me an Object[], like all my scalar
queries do.

Unfortunately, the only stuff documentation I see about stored
procedures is how to munge the result set into an entity, but as I
said, I'm not trying to do that, just get a simple list of scalars.

Is there a right way to do this? ...programmatically?

-Walt Stoneburner, (e-mail address removed)
http://www.wwco.com/~wls/blog/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top