hibernate和mybatits執行預存程序

來源:互聯網
上載者:User

標籤:seq   commit   cat   factor   oca   div   lis   nbsp   try   

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:

public List getLocationOfVesselStatusNS(final Map paraMap){        final List retList = new ArrayList();        final String sql=" {call marinedb_ncs_p2_uat.dbo.p_PTMS_enqVslCurStatusPTMS(?)}";        Map searchMap=(Map)paraMap.get("searchMap");        final int vslId=(Integer)searchMap.get("vslId");        Object object = jdbcTemplate.execute(new CallableStatementCreator() {            public CallableStatement createCallableStatement(Connection arg0) throws SQLException {                CallableStatement cs = arg0.prepareCall(sql);                return cs;            }        }, new CallableStatementCallback() {            public Object doInCallableStatement(CallableStatement cs) throws SQLException, DataAccessException {                cs.setInt(1, vslId);                cs.execute();                List columns = new ArrayList();                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 = new HashMap();                    for (int i = 0; i < columns.size(); i++) {                        map.put(columns.get(i), rs.getString(i + 1));                    }                    retList.add(map);                }                return retList;            }        });        return retList;    }

 

hibernate和mybatits執行預存程序

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.