http://openjpa.apache.org/builds/latest/docs/manual/manual.html#jpa_overview_sqlquery_create
" In addition to SELECT statements, OpenJPA supports stored procedure invocations as SQL queries. OpenJPA will assume any SQL that does not begin with the SELECT keyword (ignoring case) is a stored procedure call, and invoke it as such at the JDBC level." On Tue, May 11, 2010 at 7:58 AM, SreeAsh < [email protected]> wrote: > > Hi, > > In our application we have to call procedures,can any one suggest me how > to > call procedure in open JPA. > > I am getting the connection and doing this method is right or wrong no > ideaa plese find the below code. > > public static String retrieveCustomerRelation(int relation, EntityManager > em) throws Exception { > String command = "{? = call relation(?)}"; > Broker broker = JPAFacadeHelper.toBroker(em); > Connection connection = (Connection)broker.getConnection(); > String str = ""; > try{ > CallableStatement cstmt = connection.prepareCall(command); > cstmt.registerOutParameter(1,Types.VARCHAR); > cstmt.setInt(2, relation); > cstmt.execute(); > str = cstmt.getString(1); > cstmt.close(); > }catch (Exception e){ > e.printStackTrace(); > }finally{ > connection.close(); > } > return str; > } > -- > View this message in context: > http://openjpa.208410.n2.nabble.com/How-To-Call-Procedure-in-OpenJPA-tp5035821p5035821.html > Sent from the OpenJPA Users mailing list archive at Nabble.com. > -- Thanks, Rick
