Example usage for org.apache.ibatis.session SqlSession update

List of usage examples for org.apache.ibatis.session SqlSession update

Introduction

In this page you can find the example usage for org.apache.ibatis.session SqlSession update.

Prototype

int update(String statement, Object parameter);

Source Link

Document

Execute an update statement.

Usage

From source file:com.onnurimotors.wm.service.WmService.java

public Object updateVehicle(HttpServletRequest request, int vid) {
    SqlSession session = sqlSession();
    VEHICLE vehicle = new VEHICLE();

    vehicle.setVEHICLE_ID(vid);/*ww w . j  a  v  a 2  s  .  c  o m*/
    if (vid == -1) {
        vehicle.setVEHICLE_ID(Integer.parseInt(request.getParameter("VEHICLE_ID")));
    }
    vehicle.setIS_NOTIFIABLE(Integer.parseInt(request.getParameter("IS_NOTIFIABLE")));
    vehicle.setMODEL(request.getParameter("MODEL"));
    vehicle.setUSER_NAME(request.getParameter("USER_NAME"));
    vehicle.setBIRTH(request.getParameter("BIRTH"));
    vehicle.setPHONE_NUMBER(request.getParameter("PHONE_NUMBER"));
    vehicle.setCOMMENT(request.getParameter("COMMENT"));

    session.update("watchman.mybatis.updateVehicle", vehicle);
    session.commit();

    session.close();

    return vehicle;
}

From source file:com.onnurimotors.wm.service.WmService.java

public VEHICLE updateVehicleUserName(HttpServletRequest request) {
    SqlSession session = sqlSession();
    VEHICLE vehicle = new VEHICLE();
    String user_name = request.getParameter("USER_NAME");
    vehicle.setVEHICLE_ID(Integer.parseInt(request.getParameter("VEHICLE_ID")));
    vehicle.setUSER_NAME(user_name);/*from ww  w . j a  va2  s  .co m*/
    session.update("watchman.mybatis.updateVehicleUserName", vehicle);
    session.commit();

    session.close();

    return vehicle;
}

From source file:com.onnurimotors.wm.service.WmService.java

public VEHICLE updateVehiclePhoneNumber(HttpServletRequest request) {
    SqlSession session = sqlSession();
    VEHICLE vehicle = new VEHICLE();
    String phone_number = request.getParameter("PHONE_NUMBER");
    vehicle.setVEHICLE_ID(Integer.parseInt(request.getParameter("VEHICLE_ID")));
    vehicle.setPHONE_NUMBER(phone_number);
    session.update("watchman.mybatis.updateVehiclePhoneNumber", vehicle);
    session.commit();/*from  ww  w.ja v  a 2  s  . c o m*/

    session.close();

    return vehicle;
}

From source file:com.onnurimotors.wm.service.WmService.java

public VEHICLE updateVehicleBirth(HttpServletRequest request) {
    SqlSession session = sqlSession();
    VEHICLE vehicle = new VEHICLE();
    String birth = request.getParameter("BIRTH");
    vehicle.setVEHICLE_ID(Integer.parseInt(request.getParameter("VEHICLE_ID")));
    vehicle.setBIRTH(birth);/* www.  j av a2s .c  om*/
    session.update("watchman.mybatis.updateVehicleBirth", vehicle);
    session.commit();

    session.close();

    return vehicle;
}

From source file:com.onnurimotors.wm.service.WmService.java

public VEHICLE updateVehicleComment(HttpServletRequest request) {
    SqlSession session = sqlSession();
    VEHICLE vehicle = new VEHICLE();
    String comment = request.getParameter("COMMENT");
    vehicle.setVEHICLE_ID(Integer.parseInt(request.getParameter("VEHICLE_ID")));
    vehicle.setCOMMENT(comment);//from   w  ww .  j  a  va  2s.  c om
    session.update("watchman.mybatis.updateVehicleComment", vehicle);
    session.commit();

    session.close();

    return vehicle;
}

From source file:com.onnurimotors.wm.service.WmService.java

public Object toggleReceivingKakao(HttpServletRequest request) {
    SqlSession session = sqlSession();
    EMPLOYEE employee = new EMPLOYEE();
    String is_receiving_kakao = request.getParameter("IS_RECEIVING_KAKAO");
    employee.setEMPLOYEE_ID(Integer.parseInt(request.getParameter("EMPLOYEE_ID")));
    if (is_receiving_kakao.equals("on")) {
        employee.setIS_RECEIVING_KAKAO(0);
    } else {/*  w  ww.ja v a 2  s .  c om*/
        employee.setIS_RECEIVING_KAKAO(1);
    }
    session.update("watchman.mybatis.updateEmployeeIsReceivingKakao", employee);
    session.commit();

    session.close();

    return employee;
}

From source file:com.raycloud.cobarclient.mybatis.spring.MySqlSessionTemplate.java

License:Apache License

/**
 * ?????/* w  w  w  .ja  v a2 s  .com*/
 *
 * @param statement
 * @param collection
 * @param <T>
 * @return
 */
private <T extends Object> int batchSync(final String statement, Collection<T> collection) {
    Map<Shard, List<T>> classifiedEntities = classify(statement, collection);
    final MultipleCauseException throwables = new MultipleCauseException();
    int counter = 0;
    for (final Map.Entry<Shard, List<T>> entry : classifiedEntities.entrySet()) {
        Environment environment = environmentMap.get(entry.getKey().getId());
        //??
        final SqlSession sqlSession = SqlSessionUtils.getSqlSession(MySqlSessionTemplate.this.sqlSessionFactory,
                ExecutorType.BATCH, MySqlSessionTemplate.this.exceptionTranslator, environment);
        try {
            for (T item : entry.getValue()) {
                sqlSession.update(statement, item);
            }
            List<BatchResult> results = sqlSession.flushStatements();
            int[] updateCounts = results.get(0).getUpdateCounts();
            for (int i = 0; i < updateCounts.length; i++) {
                int value = updateCounts[i];
                counter += value;
            }
        } catch (Throwable e) {
            Throwable unwrapped = unwrapThrowable(e);
            if (MySqlSessionTemplate.this.exceptionTranslator != null
                    && unwrapped instanceof PersistenceException) {
                Throwable translated = MySqlSessionTemplate.this.exceptionTranslator
                        .translateExceptionIfPossible((PersistenceException) unwrapped);
                if (translated != null) {
                    unwrapped = translated;
                }
            }
            throwables.add(unwrapped);
        } finally {
            SqlSessionUtils.closeSqlSession(sqlSession, MySqlSessionTemplate.this.sqlSessionFactory);
        }
    }
    if (!throwables.getCauses().isEmpty()) {
        throw new TransientDataAccessResourceException(
                "one or more errors when performing data access operations  against multiple shards",
                throwables);
    }
    return counter;
}

From source file:com.spring.dao.CiudadDAOImpl.java

@Override
public void delete(Ciudad c) {
    SqlSession session = new MyBatisUtil().getSession();
    try {//  w  w  w . ja v  a2s .c  o m
        session.update("Ciudad.delete", c);
    } finally {
        session.commit();
        session.close();
    }
}

From source file:com.spring.dao.CiudadDAOImpl.java

@Override
public void edit(Ciudad c) {
    SqlSession session = new MyBatisUtil().getSession();
    try {/*from  w w  w .  j  av  a  2 s.  c om*/
        session.update("Ciudad.edit", c);
    } finally {
        session.commit();
        session.close();
    }
}

From source file:com.sycros.SCWebConsole.business.dao.LicenseBzDaoImpl.java

License:Open Source License

@Override
public int updateLicenseInfo(SqlSession sqlSession, LicenseBzDto licenseBzDto) throws Exception {
    // TODO Auto-generated method stub
    return sqlSession.update("com.sycros.SCWebConsole.business.business-mapper.updateLicenseInfo",
            licenseBzDto);/*from  w  w  w .  j  a v a2s  .  co  m*/
}