@Override public int userJoin(User user) { SqlSession session = getSession(); int msg = session.insert("hooni.userJoin", user); close(session); return msg; }
private int aplicarOperacion(String nombreSQL, BaseBean bean, String comando) { SqlSession sqlSession = this.sqlSessionFactory.openSession(); int rowAffected = 0; try { switch (comando) { case "INSERT": rowAffected = sqlSession.insert(nombreSQL, bean); break; case "UPDATE": rowAffected = sqlSession.update(nombreSQL, bean); break; case "DELETE": rowAffected = sqlSession.delete(nombreSQL, bean); break; default: LOGGER_INFO.info("No se reconoce el comando " + comando); } if (rowAffected > 0) sqlSession.commit(); } catch (Exception e) { LOGGER_ERROR.error( "Se ha presentando el siguiente error a la hora de ejecutar el comando " + comando + " " + nombreSQL, e); } finally { sqlSession.close(); } return rowAffected; }
/** * Description:保存订单提醒<br> * * @author zouming * @version 0.1 2013-1-22上午10:48:28 * @param orderReminder * @return OrderReminder * @update 2013-1-22上午10:48:28 */ @Override public OrderReminder saveOrderReminder(OrderReminder orderReminder) { SqlSession session = this.getSqlSession(ExecutorType.SIMPLE); orderReminder.setId(getSequence()); session.insert(NAMESPACE_ORDERREMINDER + INSERT_ORDERREMINDER, orderReminder); return orderReminder; }
@Test public void testInserUser() throws ParseException { // 通过sqlSessionFactory创建sqlSession SqlSession sqlSession = sqlSessionFactory.openSession(); // 通过sqlSession操作数据库 // 插入对象 User user = new User(); user.setUsername("李泽贤"); user.setAddress("广西南宁"); user.setSex("男"); SimpleDateFormat date = new SimpleDateFormat("yyyy-MM-dd"); Date birthday = date.parse("1993-05-06"); user.setBirthday(birthday); try { // 第一个参数:statement位置,等于namespace+statement的id // 第二个参数:传入的参数 sqlSession.insert("test.inserUser", user); sqlSession.commit(); } catch (Exception e) { // TODO: handle exception e.printStackTrace(); } finally { sqlSession.close(); } System.out.println("返回的主键" + user.getId()); }
/** * 新增資費佣金資料 * * @return int 筆數 * @throws Exception */ public boolean insert(TeleratesVo vo) throws Exception { SqlSession session = null; boolean status = false; int cnt = 0; try { session = getSession(false); cnt = session.insert("teleRates.insert", vo); session.commit(); if (cnt > 0) { status = true; } // StoreMonitorService.notifyCustomerQualifyTagChange(); StoreMonitorService.notifyDataTagChange(); StoreMonitorService.notifyVoiceTagChange(); } catch (Exception e) { e.printStackTrace(); logger.error(e.getMessage()); session.rollback(); throw e; } finally { closeCoonnection(session); } return status; }
@Override public <T> void batchAdd(String mapperId, List<T> t) { SqlSession session = sqlSessionFactory.openSession(ExecutorType.BATCH, false); session.insert(mapperId, t); session.commit(); }
/** * Description:保存订单提醒列表<br> * * @author zouming * @version 0.1 2013-1-22上午10:49:10 * @param orderReminderList * @update 2013-1-22上午10:49:10 */ @Override public void saveOrderReminderList(List<OrderReminder> orderReminderList) { SqlSession session = this.getSqlSession(ExecutorType.SIMPLE); for (OrderReminder orderReminder : orderReminderList) { orderReminder.setId(getSequence()); session.insert(NAMESPACE_ORDERREMINDER + INSERT_ORDERREMINDER, orderReminder); } }
protected void insert(String sqlKey, Object object) { SqlSession session = sqlSessionFactory.openSession(); try { session.insert(sqlKey, object); } finally { session.close(); } }
public void insertProductInfo(Map params) { SqlSession sqlSession = sqlSessionFactory.openSession(); try { sqlSession.insert("com.quantosauros.manager.dao.ProductInfo.insertProductInfo", params); } finally { sqlSession.commit(); sqlSession.close(); } }
/** * Function to set the constraint name, communication medium and source in the assertionGroup * table * * @param assGrp Object of assertionGroup class holding the information * @throws PersistenceException */ public void setConstraintName(AssertionGroup assGrp) throws PersistenceException { SqlSession session = sf.openSession(); try { session.insert("com.cockpitconfig.objects.CommunicationMapper.setRuleName", assGrp); } finally { session.commit(); session.close(); } }
@Override public boolean add(Author author) { try { sqlSession.insert("add", author); } catch (Exception e) { return false; } return true; }
@Override public void addTranscription(final Transcription transcription) { final SqlSession session = sessions.openSession(); try { session.insert(namespace + "addTranscription", toMap(transcription)); session.commit(); } finally { session.close(); } }
/** Start implement the Region related methods */ public void insertRegion(RegionVo vo) throws Exception { SqlSession session = sqlMapper.openSession(); try { session.insert("insertRegion", vo); session.commit(); } finally { if (session != null) session.close(); } }
public static int insertNewSolution(String level_key, String desc) { SqlSession session = sqlSessionFactory.openSession(); SolutionBin newSolution = new SolutionBin(level_key, desc); int pk = session.insert("insertSolution", newSolution); session.commit(); session.close(); return pk; }
public boolean insert(MessageVO mvo) throws SQLException { // TODO Auto-generated method stub // 메세지 입력 int t = sqlSession.insert("user.messageinsert", mvo); if (t == 1) { return true; } else { return false; } }
public void setGood(Goods good) { SqlSession session = SessionFactory.getSessionFactory().openSession(); try { session.insert("UserMapper.insertGood", good); session.commit(); } catch (Exception e) { e.printStackTrace(); } finally { session.close(); } }
public int insert(Member member) throws Exception { SqlSession sqlSession = sqlSessionFactory.openSession(); try { int count = sqlSession.insert("spms.dao.MemberDao.insert", member); sqlSession.commit(); return count; } finally { sqlSession.close(); } }
public void setUser(User user) { SqlSession session = SessionFactory.getSessionFactory().openSession(); try { session.insert("UserMapper.insertUser", user); session.commit(); } catch (Exception e) { e.printStackTrace(); } finally { session.close(); } }
public static void write2(Member dto) { // System.out.println("1.어디까지 오는걸까? : " + dto.getMember_name()); SqlSession session = sqlFactory.openSession(); try { session.insert("write2", dto); // boardMapper.xml에 id가 write인 메서드에 dto를 param으로 넘겨준다. session.commit(); // insert, update, delete는 commit()을 해줘야 완성이 된다. } catch (Exception err) { System.out.println("write2" + err); } finally { session.close(); } }
public HotelDirectoryServicios add(HotelDirectoryServicios hotelDirectoryServicios) { SqlSession session = sql.openSession(); try { session.insert("SqlMapHotelDirectoryServicios.add", hotelDirectoryServicios); session.commit(); } catch (Exception e) { Logger.getLogger(this.getClass()).error(e.getMessage()); } finally { session.close(); } return hotelDirectoryServicios; }
public Object execute(SqlSession sqlSession, Object[] args) { Object result; switch (command.getType()) { case INSERT: { Object param = method.convertArgsToSqlCommandParam(args); result = rowCountResult(sqlSession.insert(command.getName(), param)); break; } case UPDATE: { Object param = method.convertArgsToSqlCommandParam(args); result = rowCountResult(sqlSession.update(command.getName(), param)); break; } case DELETE: { Object param = method.convertArgsToSqlCommandParam(args); result = rowCountResult(sqlSession.delete(command.getName(), param)); break; } case SELECT: if (method.returnsVoid() && method.hasResultHandler()) { executeWithResultHandler(sqlSession, args); result = null; } else if (method.returnsMany()) { result = executeForMany(sqlSession, args); } else if (method.returnsMap()) { result = executeForMap(sqlSession, args); } else if (method.returnsCursor()) { result = executeForCursor(sqlSession, args); } else { Object param = method.convertArgsToSqlCommandParam(args); result = sqlSession.selectOne(command.getName(), param); } break; case FLUSH: result = sqlSession.flushStatements(); break; default: throw new BindingException("Unknown execution method for: " + command.getName()); } if (result == null && method.getReturnType().isPrimitive() && !method.returnsVoid()) { throw new BindingException( "Mapper method '" + command.getName() + " attempted to return null from a method with a primitive return type (" + method.getReturnType() + ")."); } return result; }
@Override public Object registrarUsuario(UsuarioDTO objUsuario) throws Exception { Boolean result = false; SqlSession session = sqlMapper.openSession(); try { session.insert("usuario.SQL_registraUsuario", objUsuario); session.commit(); result = true; } finally { session.close(); } return result; }
public static void insertDytt(Dytt dytt) { SqlSession sqlSession = sqlSessionFactory.openSession(); try { sqlSession.insert("com.ksosoft.insertDytt", dytt); sqlSession.commit(); } catch (Exception e) { e.printStackTrace(); logger.error(e.toString()); } finally { sqlSession.close(); } }
/** * 插入用户 * * @return 用户id */ public int insertUser(User user) { int id = 0; SqlSession session = getSession(); try { id = session.insert("user.insertUser", user); session.commit(); } catch (Exception e) { System.out.println("Dao层insertUser方法异常......"); e.printStackTrace(); } finally { session.close(); } return id; }
public static int getLibID(String level_key, String lib_desc) { int _id = -1; SqlSession session = sqlSessionFactory.openSession(); try { _id = session.selectOne("selectLib", lib_desc); } catch (NullPointerException e) { LibraryBin bin = new LibraryBin(level_key, lib_desc, 0); session.insert("insertLib", bin); _id = bin.getLib_id(); } finally { session.commit(); session.close(); } return _id; }
public static int getMethodID(String level_key, String method_desc) { int _id = -1; SqlSession session = sqlSessionFactory.openSession(); try { _id = session.selectOne("selectMethod", method_desc); } catch (NullPointerException e) { MethodBin bin = new MethodBin(level_key, method_desc, 0); session.insert("insertMethod", bin); _id = bin.getMethod_id(); } finally { session.commit(); session.close(); } return _id; }
public static int getLangID(String language_desc) { int lang_id = -1; SqlSession session = sqlSessionFactory.openSession(); try { lang_id = session.selectOne("selectLang", language_desc); } catch (NullPointerException e) { LangBin bin = new LangBin(language_desc, 0); session.insert("insertLang", bin); lang_id = bin.getLang_id(); } finally { session.commit(); session.close(); } return lang_id; }
public static int getErrorID(String level_key, String error_desc) { int _id = -1; SqlSession session = sqlSessionFactory.openSession(); try { _id = session.selectOne("selectError", error_desc); } catch (NullPointerException e) { ErrorBin bin = new ErrorBin(level_key, error_desc, 0); session.insert("insertError", bin); _id = bin.getError_id(); } finally { session.commit(); session.close(); } return _id; }
/** * 新增專案 * * @return boolean * @throws Exception */ public boolean insertNewProjectAndAttribut(ProjectVo vo, List<Projects_attributeJsonVo> avo) throws Exception { SqlSession session = null; boolean status = false; int cnt = 0; int cntAvo = 0; String json = ""; try { logger.debug("insertNewProjectAndAttribut entry ======"); session = getSession(false); // insert a new major project cnt = session.insert("project.insertProject", vo); // setting the project id to attributes for (Projects_attributeJsonVo d : avo) { d.setPid(vo.getId()); } // transfer the attributes to its JsonVo ProjectJsonVo pvo = new ProjectJsonVo(); pvo.setMajorPrjAttributes(avo); // to Json Gson gson = new Gson(); json = gson.toJson(pvo); DB_jsonMappingVo dbMapVo = new DB_jsonMappingVo(); dbMapVo.setId(vo.getId()); dbMapVo.setJson(json); cnt = session.update("project.updateProjectAttribute", dbMapVo); if (cnt > 0) { status = true; } session.commit(); } catch (Exception e) { e.printStackTrace(); logger.error(e.getMessage()); session.rollback(); throw e; } finally { closeCoonnection(session); } return status; }
@Override public int addNotice(Notice notice) { // TODO Auto-generated method stub SqlSession session = factory.openSession(); int result = 0; try { result = session.insert("com.fantastic.web.dao.NoticeDao.addNotice", notice); session.commit(); } finally { session.rollback(); session.close(); } return result; }