I'm using Hibernate to programmatically generate my database using the SchemeExport class, and it works great.
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. Hence, I may have limited experience with the following...
I need to be able to insert a stored procedure, provided by someone else, into the database and then invoke it; the procedure has nothing to do with any @Entity objects. (Hibernate is our only access to the database.)
While I can, and do, call SQL directly with session.createQuery() easily enough, the real question is
can I somehow bundle the stored procedure with the app using Hibernate, as that's how I generate my DDL from scratch?
What I'd like to see is that there's a way I can say in my hibernate.cfg.xml file something like:
Quote:
<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.
Ever hopeful, I like to then do a session.getNamedQuery("blah") and execute it by name, having it return me an Object[], like all my scalar queries do for Hibernate.
I'd hate to have to post-process an exported DDL file, or worse, muddle directly with the database, for configuration management reasons.
Unfortunately, the only stuff documentation I see on Google is about stored procedures munging 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? ...with Hibernate?
-Walt Stoneburner | Hibernate 3.2 / Annotations 3.3.0.GA