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

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

Introduction

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

Prototype

<T> T selectOne(String statement, Object parameter);

Source Link

Document

Retrieve a single row mapped from the statement key and parameter.

Usage

From source file:fr.cph.stock.dao.CurrencyDaoImpl.java

License:Apache License

/**
 * Get one currency data/* w  w  w . j  a v  a 2  s.c om*/
 * 
 * @param currencyD
 *            the currency data
 * @return a currency data
 */
public final CurrencyData selectOneCurrencyDataWithParam(final CurrencyData currencyD) {
    SqlSession session = getSqlSessionFactory();
    CurrencyData currencyData = null;
    try {
        currencyData = session.selectOne("CurrencyData.selectOneCurrencyDataWithParam", currencyD);
    } finally {
        session.close();
    }
    return currencyData;
}

From source file:fr.cph.stock.dao.EquityDaoImpl.java

License:Apache License

@Override
public final Equity select(final int id) {
    SqlSession session = getSqlSessionFactory();
    Equity equity = null;//from w w w.j  av a  2 s .  c  o m
    try {
        equity = session.selectOne("EquityDao.selectOneEquity", id);
    } finally {
        session.close();
    }
    return equity;
}

From source file:fr.cph.stock.dao.FollowDaoImpl.java

License:Apache License

@Override
public final Follow select(final int id) {
    SqlSession session = getSqlSessionFactory();
    Follow follow = null;//  ww  w .  ja v  a  2s.com
    try {
        follow = session.selectOne("FollowDao.selectOneFollow", id);
    } finally {
        session.close();
    }
    return follow;
}

From source file:fr.cph.stock.dao.FollowDaoImpl.java

License:Apache License

/**
 * Get on company that the user follow//from   w  w  w  .j a  va  2 s .c om
 * 
 * @param userId
 *            the user id
 * @param companyId
 *            the company id
 * @return a Follow object
 */
public final Follow selectOneFollow(final int userId, final int companyId) {
    SqlSession session = getSqlSessionFactory();
    Follow follow = null;
    Map<String, Integer> map = new HashMap<String, Integer>();
    map.put("userId", userId);
    map.put("companyId", companyId);
    try {
        follow = session.selectOne("FollowDao.selectOneFollow", map);
    } finally {
        session.close();
    }
    return follow;
}

From source file:fr.cph.stock.dao.IndexDaoImpl.java

License:Apache License

@Override
public final Index select(final int id) {
    SqlSession session = getSqlSessionFactory();
    Index index = null;/*w  ww  . ja v a 2 s.  c o m*/
    try {
        index = session.selectOne("IndexDao.selectOneIndex", id);
    } finally {
        session.close();
    }
    return index;
}

From source file:fr.cph.stock.dao.IndexDaoImpl.java

License:Apache License

/**
 * Get Index from DB//from   w  w w  .  j ava 2s  .  c o m
 * 
 * @param ind
 *            the index
 * @return an index
 */
public final Index selectOneIndexWithIdAndIndex(final Index ind) {
    SqlSession session = getSqlSessionFactory();
    Index index = null;
    try {
        index = session.selectOne("IndexDao.selectOneIndexWithIdAndIndex", ind);
    } finally {
        session.close();
    }
    return index;
}

From source file:fr.cph.stock.dao.IndexDaoImpl.java

License:Apache License

/**
 * Get last Index//from w ww.  jav a  2  s.  c om
 * 
 * @param yahooId
 *            the index requested
 * @return and Index with last data
 */
public final Index selectLast(final String yahooId) {
    SqlSession session = getSqlSessionFactory();
    Index index = null;
    try {
        index = session.selectOne("IndexDao.selectLastIndex", yahooId);
    } finally {
        session.close();
    }
    return index;
}

From source file:fr.cph.stock.dao.PortfolioDaoImpl.java

License:Apache License

@Override
public final Portfolio select(final int id) {
    SqlSession session = getSqlSessionFactory();
    Portfolio portfolioResult = null;/*from www . j a  va2s .c  o  m*/
    try {
        portfolioResult = session.selectOne("PortfolioDao.selectOnePortfolio", id);
    } finally {
        session.close();
    }
    return portfolioResult;
}

From source file:fr.cph.stock.dao.PortfolioDaoImpl.java

License:Apache License

/**
 * Get portfolio with user id/*from ww  w.  jav  a  2 s . c om*/
 * 
 * @param userId
 *            the user id
 * @return a Portfolio
 */
public final Portfolio selectPortfolioWithId(final int userId) {
    SqlSession session = getSqlSessionFactory();
    Portfolio portfolioResult = null;
    try {
        portfolioResult = session.selectOne("PortfolioDao.selectPortfolioWithId", userId);
    } finally {
        session.close();
    }
    return portfolioResult;
}

From source file:fr.cph.stock.dao.PortfolioDaoImpl.java

License:Apache License

/**
 * Get portfolio, loaded with its equities
 * /*from   w w w  .  j  av a2 s . co  m*/
 * @param userId
 *            the user id
 * @param from
 *            the from date
 * @param to
 *            the to date
 * @return a portfolio
 */
public final Portfolio selectPortfolioFromUserIdWithEquities(final int userId, final Date from, final Date to) {
    SqlSession session = getSqlSessionFactory();
    Portfolio portfolio = null;
    try {
        portfolio = session.selectOne("PortfolioDao.selectPortfolioWithId", userId);
        if (portfolio != null) {
            List<Equity> equities = session.selectList("PortfolioDao.selectEquityFromPortfolio",
                    portfolio.getId());
            portfolio.setEquities(equities);
            List<Account> accounts = session.selectList("AccountDao.selectAllAccountWithUserId", userId);
            portfolio.setAccounts(accounts);
            if (from == null) {
                List<ShareValue> shares = session.selectList("ShareValue.selectAllValue", userId);
                portfolio.setShareValues(shares);
            } else {
                Map<String, Object> map = new HashMap<String, Object>();
                map.put("userId", userId);
                map.put("from", from);
                if (to == null) {
                    List<ShareValue> shares = session.selectList("ShareValue.selectShareValueFrom", map);
                    portfolio.setShareValues(shares);
                } else {
                    map.put("to", to);
                    List<ShareValue> shares = session.selectList("ShareValue.selectShareValueFromTo", map);
                    portfolio.setShareValues(shares);
                }

            }
        }
    } finally {
        session.close();
    }
    return portfolio;
}