/** @Title: getOrderAcceptInfoByDept @Description: 查询制定部门的待受理订单数量 */ @Override public OrderAcceptInfo getOrderAcceptInfoByDept(OrderAcceptConfig oac, String standardCode) { oac.setStandardCode(standardCode); SqlSession session = this.getSqlSession(ExecutorType.SIMPLE); return (OrderAcceptInfo) session.selectOne(NAMESPACE_ORDERREMINDER + "generateOrderAcceptInfo", oac); }
@Override public int selectCount() { int count = 0; SqlSession session = util.getSqlsession(); count = ((Integer) session.selectOne("log.selectCount")).intValue(); return count; }
/** @param args */ public static void main(String[] args) { InputStream inputStream = null; try { inputStream = Resources.getResourceAsStream("org/mybatis/example/config.properties"); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } Properties p = null; try { p = new Properties(); // load file p.load(inputStream); } catch (Exception e) { e.printStackTrace(); } String resource = "org/mybatis/example/mybatis-config.xml"; try { inputStream = Resources.getResourceAsStream(resource); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream, p); SqlSession session = sqlSessionFactory.openSession(); try { Blog blog = (Blog) session.selectOne("org.mybatis.example.BlogMapper.selectBlog", 101); } finally { session.close(); } }
@Override public T queryOne(T t) { SqlSession sqlSession = sqlSessionFactory.openSession(false); t = sqlSession.selectOne(namespace.concat("queryOne"), t); sqlSession.close(); return t; // 返回类型为T }
@Test public void learnToCallStoredFunction2() { // Store 1 does have inventory, so the answer is true Boolean b = session.selectOne("inventoryInStoreBoolean", 1); assertNotNull(b); assertTrue(b); }
@Override public log getLog(log u) { log usr = null; SqlSession session = util.getSqlsession(); usr = (log) session.selectOne("log.selectOne", u); return usr; }
@Override public UserProfile checkAuthenticationDB(String username, String password) throws Exception { SqlSession session = SqlMapConfig.getSqlSession(false); try { // Run command ---------------------------------------------------- Map<String, Object> map = new HashMap<String, Object>(); map.put("username", username); map.put("password", password); UserProfile userProfile = session.selectOne("UserProfile.getUserProfile", map); session.commit(); return userProfile; } catch (Exception e) { session.rollback(); throw e; } finally { session.clearCache(); session.close(); session = null; } }
@Override public Map getTechnologyDetail(technology tg) { Map mp = getAllInfo(); SqlSession session = util.getSqlsession(); technology ns = (technology) session.selectOne("technology.selectOneById", tg); mp.put("technologyDetail", ns); return mp; }
public Member selectByEmailPassword(Map<String, String> paramMap) throws Exception { SqlSession sqlSession = sqlSessionFactory.openSession(); try { return sqlSession.selectOne("spms.dao.MemberDao.selectByEmailPassword", paramMap); } finally { sqlSession.close(); } }
@Override public Map getKnowledgeDetail(knowledge kl) { Map mp = getAllInfo(); SqlSession session = util.getSqlsession(); knowledge ns = (knowledge) session.selectOne("knowledge.selectOneById", kl); mp.put("knowledgeDetail", ns); return mp; }
protected Integer selectOneAsInt(String sqlKey) { SqlSession session = sqlSessionFactory.openSession(); try { return (Integer) session.selectOne(sqlKey); } finally { session.close(); } }
@Override public Map getNewsDetail(news nw) { Map mp = getAllInfo(); SqlSession session = util.getSqlsession(); news ns = (news) session.selectOne("news.selectOneById", nw); mp.put("newsDetail", ns); return mp; }
@Override public Map getProductDetail(product nw) { Map mp = getAllInfo(); SqlSession session = util.getSqlsession(); product ns = (product) session.selectOne("product.selectOneById", nw); mp.put("productDetail", ns); return mp; }
@Override public Map getStudentDetail(student st) { Map mp = getAllInfo(); SqlSession session = util.getSqlsession(); student ns = (student) session.selectOne("student.selectOneById", st); mp.put("studentDetail", ns); return mp; }
public Member selectOne(int no) throws Exception { SqlSession sqlSession = sqlSessionFactory.openSession(); try { return sqlSession.selectOne("spms.dao.MemberDao.selectOne", no); } finally { sqlSession.close(); } }
@Override public Map getTeamDetail(team tm) { Map mp = getAllInfo(); SqlSession session = util.getSqlsession(); team ns = (team) session.selectOne("team.selectOneById", tm); mp.put("teamDetail", ns); return mp; }
@Test public void findUserById() throws IOException { InputStream inputStream = Resources.getResourceAsStream("SqlMapConfig.xml"); SqlSessionFactory sessionFactory = new SqlSessionFactoryBuilder().build(inputStream); SqlSession sqlSession = sessionFactory.openSession(); User user = sqlSession.selectOne("test.findUserId", 1); System.out.println(user); sqlSession.close(); }
@Override public Author getAuthor(String id) { try { return sqlSession.selectOne("getAuthor", id); } catch (Exception e) { e.printStackTrace(); return null; } }
/** * @param type The return type * @param sqlKey The iBatis SQL key * @param parameter To select with * @return The casted result * @throws IOException On error */ @SuppressWarnings("unchecked") protected <T> T selectOne(Class<T> type, String sqlKey, Object parameter) { SqlSession session = sqlSessionFactory.openSession(); try { return (T) session.selectOne(sqlKey, parameter); } finally { session.close(); } }
@Override public MemberVO readWithPW(String userid, String userpw) throws Exception { // TODO Auto-generated method stub Map<String, Object> paramMap = new HashMap<String, Object>(); paramMap.put("userid", userid); paramMap.put("userpw", userpw); return sqlSession.selectOne(namespace + ".readWithPW", paramMap); }
public Info selectById(int id) { SqlSession session = sqlSessionFactory.openSession(); try { Info info = (Info) session.selectOne("Info.getById", id); return info; } finally { session.close(); } }
@Override public User userDetail(String userId) { SqlSession session = getSession(); User user = session.selectOne("hooni.userDetail", userId); close(session); return user; }
public ProductInfoModel selectProductInfoByInstrumentCd(String instrumentCd) { SqlSession sqlSession = sqlSessionFactory.openSession(); try { return sqlSession.selectOne( "com.quantosauros.manager.dao.ProductInfo.getProductInfoByInstrumentCd", instrumentCd); } finally { sqlSession.close(); } }
public User getUserByEmail(String email) { SqlSession session = SessionFactory.getSessionFactory().openSession(); User user; try { user = (User) session.selectOne("UserMapper.selectUser", email); } finally { session.close(); } return user; }
@Override public Map getJoinInfo() { Map mp = getAllInfo(); SqlSession session = util.getSqlsession(); join jx = new join(); jx.setId("1"); join jn = (join) session.selectOne("join.selectOneById", jx); mp.put("join", jn); return mp; }
protected synchronized void getNewBlock(SqlSession session, Object object) { IdBlock idBlock = session.selectOne("", idBlockSize); // TODO http://jira.codehaus.org/browse/ACT-45 use a separate // 'requiresNew' command executor // IdBlock idBlock = commandExecutor.execute(new // GetNextIdBlockCmd(idBlockSize)); this.nextId = idBlock.getNextId(); this.lastId = idBlock.getLastId(); }
public User getUserById(long id) { SqlSession session = SessionFactory.getSessionFactory().openSession(); User user; try { user = (User) session.selectOne("UserMapper.getUserById", id); } finally { session.close(); } return user; }
@Test public void sfTest() throws Exception { SqlSession s = sf.openSession(); logger.info("---------------------------------------------"); logger.info(s.selectOne("com.kr.spt.mappers.Timer.getTime")); logger.info("---------------------------------------------"); s.close(); }
public Goods getGoodsById(long id) { SqlSession session = SessionFactory.getSessionFactory().openSession(); Goods goods; try { goods = session.selectOne("UserMapper.selectGoodsById", id); } finally { session.close(); } return goods; }
public static void main(String[] args) { String resource = "conf.xml"; InputStream is = Test.class.getClassLoader().getResourceAsStream(resource); SqlSessionFactory factory = new SqlSessionFactoryBuilder().build(is); SqlSession session = factory.openSession(); String statement = "com.mybatis.test1.userMapper.getUser"; User user = session.selectOne(statement, 2); session.close(); System.out.println(user); }