-->
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.  [ 3 posts ] 
Author Message
 Post subject: Create stored procedure on Hibernate init
PostPosted: Tue Oct 07, 2008 9:22 pm 
Newbie

Joined: Tue Oct 07, 2008 9:09 pm
Posts: 4
Hi guys we make extensive use of hibernate in our project but for BIRT reporting we are using straight JDBC queries. The reporting component has grown such that there is now a need for a stored procedure to do some heavy lifting for us. I want to know if as part of the hibernate start up where by it will create a schema, tables etc etc can I specify a stored procedure that is created at the same time. This would save us having a post creation script that runs after initial start up to initialise the environment.

I understand that doing so will likey tie us closer to a vendor than the hibernate dream would have it, but we are wed to the vendor and this will no longer pose a problem.


Cheers,
Mik.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 07, 2008 9:42 pm 
Newbie

Joined: Tue Oct 07, 2008 9:09 pm
Posts: 4
I should probably add that this is the code frag that I'd like to add

Code:
CREATE OR REPLACE FUNCTION getCurrentDiagnosis(htcid integer) RETURNS SETOF integer AS $$
    DECLARE
        currentDiagnosis RECORD;
        currentPatient RECORD;
    BEGIN
   FOR currentPatient IN SELECT subject.*
            from subject, patientsitemember
            where subject.id = patientsitemember.patient
            and patientsitemember.htcsite = htcid LOOP
      SELECT INTO currentDiagnosis diagnosis.* FROM diagnosis, patientstatus
                  where diagnosis.diagnosisid = patientstatus.patientstatusid
                  and patientstatus.patientid = currentPatient.id
                  order by diagnosis.diagnosisdate desc, diagnosis.diagnosisid desc
                  limit 1;
      RETURN NEXT currentDiagnosis.bleedingdisorder;
   END LOOP;
    END;
$$ LANGUAGE plpgsql;


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 07, 2008 10:27 pm 
Newbie

Joined: Tue Oct 07, 2008 9:09 pm
Posts: 4
Bam!

http://www.hibernate.org/hib_docs/reference/en/html/mapping-database-object.html


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

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.