users@glassfish.java.net

Re: Is it possible to call a Stored Procedure from JPA(TopLink)?

From: <glassfish_at_javadesktop.org>
Date: Fri, 26 Sep 2008 12:14:42 PDT

Yes it's possible to call Stored Procedure. At least it works in my application with MS SQL Server and Glassfish 2.1

Here is example:

  public void doMerge(int sourcePatientId, int destinationPatientId) {
    Query query = getEntityManager().createNativeQuery("{call dbo.MergePatient(?,?)}");
    query.setParameter(1, sourcePatientId);
    query.setParameter(2, destinationPatientId);
    getEntityManager().getTransaction().begin();
    query.executeUpdate();
    getEntityManager().getTransaction().commit();
  }
[Message sent by forum member 'vladperl' (vladperl)]

http://forums.java.net/jive/thread.jspa?messageID=301882