openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From SreeAsh <srinivasulu.krist...@fs.mphasis.com>
Subject How To Call Procedure in OpenJPA
Date Wed, 10 Feb 2010 04:48:58 GMT

Hi Please suggest me on this.

I am calling the procedure as follows, is there any impact in can i use this
code.

    //emf =
Factory.getEntityManager(PersistenceConstants.SQLSERVER_PERSISIT_UNIT);
        em = emf.createEntityManager();
        String command = "{? = call Proc_KeyGen(?,?)}";
        Broker broker = JPAFacadeHelper.toBroker(em); 
        JDBCStore store = (JDBCStore)broker.getStoreManager();
        Connection connection = store.getConnection();
        String str = null;
        try {
            CallableStatement cstmt = connection.prepareCall(command);
            cstmt.registerOutParameter(1, Types.VARCHAR);
            cstmt.setString(2, "");
            cstmt.registerOutParameter(3, Types.VARCHAR);
            cstmt.execute();
            str = cstmt.getString(3);
            //unitOfWorkImpl.commit();
            cstmt.close();
            System.out.println("Primary::" + str);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            connection.close();
            em.close();
            emf.close();
        }
        return str;
    }

regards
Srini
-- 
View this message in context: http://n2.nabble.com/How-To-Call-Procedure-in-OpenJPA-tp4545967p4545967.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Mime
View raw message