Hibernate:
private string Getnewseq (String eService) {string no = ""; Session session = Getsessionfactory (). Opensession (); Transaction tx = null;try {tx = Session.begintransaction (); CallableStatement call = Session.connection (). Preparecall ("{Call PF_GENREFNO (?,?)}"); Call.setstring (1, EService); Call.registeroutparameter (2, Types.varchar); Call.execute (); no = call.getstring (2); Tx.commit ();} catch (SQLException e) {log.error (E.getmessage (), e);} Finally{if (Session! = null) { try { session.close (); } catch (hibernateexception e) { log.error (E.getmessage (), E); } }} return no;}
Mybatits:
PublicList Getlocationofvesselstatusns (FinalMap Paramap) { FinalList retlist =NewArrayList (); FinalString sql= "{call Marinedb_ncs_p2_uat.dbo.p_PTMS_enqVslCurStatusPTMS (?)}"; Map Searchmap= (MAP) paramap.get ("Searchmap"); Final intVslid= (Integer) searchmap.get ("Vslid"); Object Object= Jdbctemplate.execute (NewCallableStatementCreator () { PublicCallableStatement createcallablestatement (Connection arg0)throwsSQLException {CallableStatement cs=arg0.preparecall (SQL); returnCS; } }, NewCallableStatementCallback () { PublicObject doincallablestatement (CallableStatement cs)throwsSQLException, DataAccessException {cs.setint (1, Vslid); Cs.execute (); List Columns=NewArrayList (); Columns.Add ("Vsl_x"); Columns.Add ("Vslprev_x"); Columns.Add ("Vsllstp_x"); Columns.Add ("Vslnxp_x"); Columns.Add ("Vslcallsign_x"); Columns.Add ("Licno_x"); Columns.Add ("Vslty_x"); Columns.Add ("Vslflag_x"); Columns.Add ("Vslgt_x"); Columns.Add ("Vsllen_x"); Columns.Add ("Vsldeclrarr_x"); Columns.Add ("Vsldeclrdep_x"); Columns.Add ("Agent_x"); Columns.Add ("Mvstm_eta_x"); Columns.Add ("Mvetm_eta_x"); Columns.Add ("Mvstm_etd_x"); Columns.Add ("Mvetm_etd_x"); Columns.Add ("Currlocn_x"); Columns.Add ("Vslimo_x"); ResultSet RS=Cs.getresultset (); while(Rs.next ()) {map map=NewHashMap (); for(inti = 0; I < columns.size (); i++) {map.put (Columns.get (i), rs.getstring (i+ 1)); } retlist.add (map); } returnretlist; } }); returnretlist; }
Hibernate and mybatits Execute stored procedures