Non-Entity Related Stored Procedures in Hibernate

Discussion in 'Java' started by wls, Nov 8, 2007.

  1. wls

    wls Guest

    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,
    http://www.wwco.com/~wls/blog/
     
    wls, Nov 8, 2007
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Steve

    Entity EJBs vs Hibernate ?

    Steve, Sep 25, 2005, in forum: Java
    Replies:
    2
    Views:
    1,848
    Tor Iver Wilhelmsen
    Sep 28, 2005
  2. Samuel van Laere

    Entity Name or Entity Number?

    Samuel van Laere, Feb 24, 2007, in forum: HTML
    Replies:
    4
    Views:
    1,742
    Jukka K. Korpela
    Feb 24, 2007
  3. markla
    Replies:
    1
    Views:
    580
    Steven Cheng
    Oct 6, 2008
  4. Norm
    Replies:
    3
    Views:
    2,880
  5. ThatsIT.net.au

    Entity, problem with entity key

    ThatsIT.net.au, Sep 6, 2009, in forum: ASP .Net
    Replies:
    1
    Views:
    1,244
    ThatsIT.net.au
    Sep 7, 2009
Loading...

Share This Page