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

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

Introduction

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

Prototype

int delete(String statement, Object parameter);

Source Link

Document

Execute a delete statement.

Usage

From source file:com.inform.project.dao.MyBatisGetCategoryImpl.java

@Override
public void delCategory(UserCategoryModel category) {
    SqlSession session = null;
    try {/*  w  ww  .ja va 2 s.c om*/
        session = MyBatisSession.getInst().getSession().openSession();
        session.delete("GetUsersCategoryMapper.deleteOne", category);
        session.commit();
    } catch (IOException ex) {
        Logger.getLogger(MyBatisAdminImpl.class.getName()).log(Level.SEVERE, null, ex);
    } finally {
        if (session != null) {
            session.close();
        }
    }
}

From source file:com.inform.project.dao.MyBatisGetEventsImpl.java

@Override
public void deleteEvent(EventModel event) {
    SqlSession session = null;
    try {//from   www  . j  ava2s. com
        session = MyBatisSession.getInst().getSession().openSession();
        session.delete("GetEventsModelMapper.deleteOne", event);
        session.commit();
    } catch (IOException ex) {
        Logger.getLogger(MyBatisAdminImpl.class.getName()).log(Level.SEVERE, null, ex);
    } finally {
        if (session != null) {
            session.close();
        }
    }
}

From source file:com.inform.project.dao.MyBatisGetLocationImpl.java

@Override
public void delLocation(UserLocationModel loc) {
    SqlSession session = null;
    try {/*from   w w w  .  ja va2 s.c om*/
        session = MyBatisSession.getInst().getSession().openSession();
        session.delete("GetUsersLocationMapper.deleteOne", loc);
        session.commit();
    } catch (IOException ex) {
        Logger.getLogger(MyBatisAdminImpl.class.getName()).log(Level.SEVERE, null, ex);
    } finally {
        if (session != null) {
            session.close();
        }
    }
}

From source file:com.inform.project.dao.MyBatisGetSellsImpl.java

@Override
public void delSells(UserSellsModel sell) {
    SqlSession session = null;
    try {/*from  w  ww  . j av a 2  s .c  o m*/
        session = MyBatisSession.getInst().getSession().openSession();
        session.delete("GetUsersSellsMapper.deleteOne", sell);
        session.commit();
    } catch (IOException ex) {
        Logger.getLogger(MyBatisAdminImpl.class.getName()).log(Level.SEVERE, null, ex);
    } finally {
        if (session != null) {
            session.close();
        }
    }
}

From source file:com.mirth.connect.plugins.datapruner.DataPruner.java

License:Open Source License

private void pruneEvents() {
    logger.debug("Pruning events");
    status.setPruningEvents(true);//from w  w  w  .  j  a va2s .  c  o m

    try {
        status.setTaskStartTime(Calendar.getInstance());

        Calendar dateThreshold = Calendar.getInstance();
        dateThreshold.set(Calendar.DAY_OF_MONTH, dateThreshold.get(Calendar.DAY_OF_MONTH) - maxEventAge);

        SqlSession session = SqlConfig.getSqlSessionManager().openSession(true);

        try {
            Map<String, Object> params = new HashMap<String, Object>();
            params.put("dateThreshold", dateThreshold);

            int numEventsPruned = session.delete("Message.pruneEvents", params);

            Map<String, String> attributes = new HashMap<String, String>();
            attributes.put("Events Pruned", Integer.toString(numEventsPruned));
            attributes.put("Time Elapsed", getTimeElapsed());
            eventController.dispatchEvent(new ServerEvent(serverId, DataPrunerService.PLUGINPOINT,
                    Level.INFORMATION, Outcome.SUCCESS, attributes));
        } finally {
            session.close();
        }
    } finally {
        status.setEndTime(Calendar.getInstance());
        status.setPruningEvents(false);
    }
}

From source file:com.mirth.connect.plugins.datapruner.DataPruner.java

License:Open Source License

private int runDelete(String query, Map<String, Object> params) {
    SqlSession session = SqlConfig.getSqlSessionManager().openSession(true);

    try {/*  w ww . ja v a  2 s.c o m*/
        if (DatabaseUtil.statementExists("initDataPruner", session)) {
            session.update("initDataPruner");
        }

        status.setPruning(true);

        int count = session.delete(query, params);
        return count;
    } finally {
        session.close();
        status.setPruning(false);
    }
}

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

public Object deleteVehicle(int vehicle_id) {
    VEHICLE vehicle = new VEHICLE();
    vehicle.setVEHICLE_ID(vehicle_id);//w  w  w  .j  a v a  2  s .  c o  m
    deleteHistoryByVehicle(vehicle_id);
    SqlSession session = sqlSession();
    session.delete("watchman.mybatis.deleteVehicle", vehicle);
    session.commit();

    session.close();

    return vehicle;
}

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

public Object deleteHistory(HttpServletRequest request, Model model, int hid) {
    SqlSession session = sqlSession();
    PARAMETER_HISTORY parameter_history = new PARAMETER_HISTORY();
    parameter_history.setHISTORY_ID(hid);
    parameter_history.setDATE_VISIT("");
    parameter_history.setVEHICLE_ID(-1);
    parameter_history.setPAGE(0);//from  ww  w  . j  av  a  2 s.c om
    parameter_history.setSIZE_PAGE(1);
    HISTORY history = (HISTORY) session.selectOne("watchman.mybatis.selectHistory", parameter_history);
    session.delete("watchman.mybatis.deleteHistory", history);
    session.commit();

    HISTORY_MANAGEMENT hm = new HISTORY_MANAGEMENT();
    hm.setMANAGEMENT_ID(-1);
    hm.setDATE_VISIT(history.getDATE_VISIT());
    hm.setVEHICLE_ID(history.getVEHICLE_ID());
    System.out.println(hm.getDATE_VISIT() + ":" + hm.getVEHICLE_ID() + ":" + hm.getMANAGEMENT_ID());
    session.delete("watchman.mybatis.deleteManagement", hm);
    session.commit();

    session.delete("watchman.mybatis.deleteHistoryManagement", hm);
    session.commit();

    session.close();

    return history;
}

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

public void deleteManagement(int mid) {
    HISTORY_MANAGEMENT hm = new HISTORY_MANAGEMENT();
    hm.setMANAGEMENT_ID(mid);/*  ww w . j av a 2  s. c o  m*/
    hm.setVEHICLE_ID(-1);
    hm.setDATE_VISIT("");

    deleteHistoryManagement(hm);

    SqlSession session = sqlSession();
    session.delete("watchman.mybatis.deleteManagement", hm);
    session.commit();

    session.close();
}

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

public void deleteManagementByVehicle(HISTORY_MANAGEMENT hm) {
    SqlSession session = sqlSession();
    hm.setMANAGEMENT_ID(-1);/*from   ww w  . j a va  2s.c  o m*/
    session.delete("watchman.mybatis.deleteManagement", hm);
    session.commit();
    session.close();
}