List of usage examples for org.apache.ibatis.session SqlSession selectOne
<T> T selectOne(String statement, Object parameter);
From source file:com.sycros.SCWebConsole.business.dao.LicenseBzDaoImpl.java
License:Open Source License
@Override public LicenseBzVo selectLicenseInfo(SqlSession sqlSession, LicenseBzDto licenseBzDto) throws Exception { // TODO Auto-generated method stub return sqlSession.selectOne("com.sycros.SCWebConsole.business.business-mapper.selectLicenseInfo", licenseBzDto);// w w w . j a va2 s . com }
From source file:com.tianjunwei.lazy.LazyMain.java
License:Apache License
public static void main(String[] args) { //mybatis?//from ww w. ja va2 s. c om String resource = "learn/mybatis-config.xml"; InputStream is = LazyMain.class.getClassLoader().getResourceAsStream(resource); //sqlSession SqlSessionFactory sessionFactory = new SqlSessionFactoryBuilder().build(is); SqlSession session = sessionFactory.openSession(); String statement = "com.tianjunwei.lazy.entity.User.getById";//sql //usersql User user = session.selectOne(statement, 1); session.commit(true); System.out.println(user.getNames()); //Teacher teacher = user.getTeacher(); //System.err.println(teacher.getName()); }
From source file:com.tianjunwei.lazy.LazyUser.java
License:Apache License
public static void main(String[] args) { //mybatis?/*from w ww .j a v a2 s . co m*/ String resource = "learn/mybatis-config.xml"; InputStream is = LazyUser.class.getClassLoader().getResourceAsStream(resource); //sqlSession SqlSessionFactory sessionFactory = new SqlSessionFactoryBuilder().build(is); SqlSession session = sessionFactory.openSession(); String statement = "com.tianjunwei.lazy.entity.Users.getUser";//sql //usersql User user = session.selectOne(statement, 1); session.commit(true); System.out.println(user.getNames()); Teacher teacher = user.getTeacher(); System.err.println(teacher.getName()); }
From source file:com.yimidida.shards.id.db.SequenceBolckIdGenerator.java
License:Open Source License
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(); }
From source file:com.yimidida.shards.select.impl.ShardSelectImpl.java
License:Open Source License
@Override @SuppressWarnings("unchecked") public <T> T getSingleResult() { ShardOperation<Object> shardOp = new ShardOperation<Object>() { public Object execute(SqlSession session, ShardId shardId) { return session.selectOne(selectFactory.getStatement(), ParameterUtil.resolve(selectFactory.getParameter(), shardId)); }//from w w w . ja va 2s . c o m public String getOperationName() { return "getSingleResult()"; } }; return (T) shardAccessStrategy.apply(shards, shardOp, new SelectOneExitStrategy(), selectCollector); }
From source file:fr.cph.stock.dao.AccountDaoImpl.java
License:Apache License
@Override public final Account select(final int id) { SqlSession session = getSqlSessionFactory(); Account accountResult = null;/*from w w w .jav a 2 s . co m*/ try { accountResult = session.selectOne("AccountDao.selectOneAccount", id); } finally { session.close(); } return accountResult; }
From source file:fr.cph.stock.dao.AccountDaoImpl.java
License:Apache License
/** * Get an account/*from www. j ava 2 s. c o m*/ * * @param userId * the user id * @param name * the name of the account * @return an account */ public final Account selectOneAccountWithName(final int userId, final String name) { SqlSession session = getSqlSessionFactory(); Account account = null; Map<String, Object> map = new HashMap<String, Object>(); try { map.put("userId", userId); map.put("name", name); account = session.selectOne("AccountDao.selectOneAccountWithName", map); } finally { session.close(); } return account; }
From source file:fr.cph.stock.dao.CompanyDaoImpl.java
License:Apache License
@Override public final Company select(final int id) { SqlSession session = getSqlSessionFactory(); Company company = null;//ww w . j a v a 2 s. c om try { company = session.selectOne("CompanyDao.selectOneCompany", id); } finally { session.close(); } return company; }
From source file:fr.cph.stock.dao.CompanyDaoImpl.java
License:Apache License
/** * Get a company/*w w w . j av a 2 s . c o m*/ * * @param yahooId * the yahoo id * @return a company */ public final Company selectWithYahooId(final String yahooId) { SqlSession session = getSqlSessionFactory(); Company company = null; try { company = session.selectOne("CompanyDao.selectOneCompanyWithYahooId", yahooId); } finally { session.close(); } return company; }
From source file:fr.cph.stock.dao.CurrencyDaoImpl.java
License:Apache License
@Override public final CurrencyData select(final int id) { SqlSession session = getSqlSessionFactory(); CurrencyData currencyData = null;// w w w . j ava2 s.com try { currencyData = session.selectOne("CurrencyData.selectOneCurrencyData", id); } finally { session.close(); } return currencyData; }