-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Non-Entity Related Stored Procedures in Hibernate
PostPosted: Thu Nov 15, 2007 2:20 pm 
Newbie

Joined: Thu Nov 15, 2007 1:36 pm
Posts: 12
Location: Ahsburn, VA
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.