You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by SreeAsh <sr...@fs.mphasis.com> on 2010/02/10 05:48:58 UTC
How To Call Procedure in OpenJPA
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.