List of usage examples for org.apache.ibatis.session SqlSession commit
void commit();
From source file:com.gordcorp.jira2db.persistence.JiraIssueDao.java
License:Open Source License
public int deleteByJiraKey(String jiraKey) throws PersistenceException { SqlSession session = sf.openSession(); int status = 0; try {/* w w w . ja v a 2 s . c om*/ String query = NAMESPACE + "." + PREFIX_DELETE_QUERY + this.type.getSimpleName() + "ByJiraKey"; status = session.delete(query, jiraKey); session.commit(); } finally { session.close(); } return status; }
From source file:com.gordcorp.jira2db.persistence.JiraIssueDao.java
License:Open Source License
public int updateByJiraKey(JiraIssueDto jiraIssueDto) { SqlSession session = sf.openSession(); int status = 0; try {/*from ww w.j av a 2 s.c om*/ String query = NAMESPACE + "." + PREFIX_UPDATE_QUERY + this.type.getSimpleName() + "ByJiraKey"; status = session.update(query, jiraIssueDto); session.commit(); } finally { session.close(); } return status; }
From source file:com.gordcorp.jira2db.persistence.MyBatisDao.java
License:Open Source License
/** * Method inserts the object into the table. </br></br> You will usually * override this method, especially if you're inserting associated objects. * </br> Example: </br> If your DAO object is called CarInfo.java, the * corresponding mapper query id should be: <insert id="createCarInfo" * ... </br></br> SQL Executed (example): insert into [tablename] * (fieldname1,fieldname2,...) values(value1,value2...) ... * /*from w ww. ja v a2 s . c o m*/ */ @Override public int create(T o) throws PersistenceException { SqlSession session = sf.openSession(); int status = -1; try { String query = NAMESPACE + "." + PREFIX_INSERT_QUERY + o.getClass().getSimpleName(); status = session.insert(query, o); // GenericDto genericDto = (GenericDto) o; // status = genericDto.getId(); session.commit(); } finally { session.close(); } return status; }
From source file:com.gordcorp.jira2db.persistence.MyBatisDao.java
License:Open Source License
/** * Method updates the object by id. </br></br> You will usually override * this method. But it can be used for simple objects. </br> Example: </br> * If your DAO object is called CarInfo.java, the corresponding mapper query * id should be: <update id="updateCarInfo" ... </br></br> SQL Executed * (example): update [tablename] set fieldname1 = value1 where id = #{id} * /*from w w w . j a v a2 s . co m*/ */ @Override public int update(T o) throws PersistenceException { SqlSession session = sf.openSession(); int status = 0; try { String query = NAMESPACE + "." + PREFIX_UPDATE_QUERY + o.getClass().getSimpleName(); status = session.update(query, o); session.commit(); } finally { session.close(); } return status; }
From source file:com.gordcorp.jira2db.persistence.MyBatisDao.java
License:Open Source License
/** * Method deletes the object by id. </br></br> Example: </br> If your DAO * object is called CarInfo.java, the corresponding mapper query id should * be: <delete id="deleteCarInfo" ... </br></br> SQL Executed (example): * update [tablename] set fieldname1 = value1 where id = #{id} * // w w w. j a v a 2 s . c om */ @Override public int delete(PK id) throws PersistenceException { SqlSession session = sf.openSession(); int status = 0; try { String query = NAMESPACE + "." + PREFIX_DELETE_QUERY + this.type.getSimpleName(); status = session.delete(query, id); session.commit(); } finally { session.close(); } return status; }
From source file:com.healthcaresolutions.hisif.datamanager.StaffManager.java
public Staff setStaffInfo(String code, String name, String lastName, String license) { Staff result = null;/*from w ww . j a va 2s. c o m*/ try { SqlSession session = SessionFactoryHelper.getSqlSessionFactory().openSession(); StaffMapper staffMapper = session.getMapper(StaffMapper.class); StaffExample example = new StaffExample(); example.createCriteria().andStaffCodeEqualTo(code); List<Staff> staffs = staffMapper.selectByExample(example); if (staffs.size() > 0) { result = staffs.get(0); result.setStaffFname(name); result.setStaffLname(lastName); result.setStaffLicense(license); staffMapper.updateByPrimaryKeySelective(result); session.commit(); } else { result = new Staff(); result.setRoleId(0); result.setStaffCode(code); result.setStaffFname(name); result.setStaffLname(lastName); result.setStaffLicense(license); result.setStaffMail(""); result.setStaffMobile(""); result.setStaffPwd(""); result.setStaffUsr(code); result.setStaffTel(""); result.setStaffTitle(""); result.setTrId(0); staffMapper.insertSelective(result); session.commit(); } session.close(); } catch (IOException ioe) { ioe.printStackTrace(); } return result; }
From source file:com.inform.project.dao.MyBatisAdminImpl.java
@Override public void deleteObject(int id) { SqlSession session = null; try {/*from w w w .j av a 2 s .co m*/ session = MyBatisSession.getInst().getSession().openSession(); session.delete("GetUsersMapper.deleteOne", id); 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.MyBatisAdminImpl.java
@Override public void addObject(LoginAuthModel user) { SqlSession session = null; try {//from ww w . j av a 2 s.c o m session = MyBatisSession.getInst().getSession().openSession(); session.insert("GetUsersMapper.insertOne", user); 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.MyBatisAdminImpl.java
@Override public void updateUser(LoginAuthModel user) { SqlSession session = null; try {/*from ww w. java2 s. c o m*/ session = MyBatisSession.getInst().getSession().openSession(); session.update("GetUsersMapper.updateOne", user); session.commit(); System.out.println("commit"); } catch (IOException ex) { System.out.println(ex); Logger.getLogger(MyBatisAdminImpl.class.getName()).log(Level.SEVERE, null, ex); } finally { if (session != null) { session.close(); } } }
From source file:com.inform.project.dao.MyBatisGetCategoryImpl.java
@Override public void setCategory(UserCategoryModel category) { SqlSession session = null; try {/*from w w w. j a va2s . c o m*/ session = MyBatisSession.getInst().getSession().openSession(); session.insert("GetUsersCategoryMapper.insertOne", category); session.commit(); } catch (IOException ex) { Logger.getLogger(MyBatisAdminImpl.class.getName()).log(Level.SEVERE, null, ex); } finally { if (session != null) { session.close(); } } }