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:org.mobicents.servlet.restcomm.dao.mybatis.MybatisRegistrationsDao.java

License:Open Source License

@Override
public boolean hasRegistration(final Registration registration) {
    final SqlSession session = sessions.openSession();
    try {/*from   w  w  w .  j  av a  2 s.c o m*/
        final Integer result = (Integer) session.selectOne(namespace + "hasRegistration", toMap(registration));
        return result != null && result > 0;
    } finally {
        session.close();
    }
}

From source file:org.mobicents.servlet.restcomm.dao.mybatis.MybatisShortCodesDao.java

License:Open Source License

@Override
public ShortCode getShortCode(final Sid sid) {
    final SqlSession session = sessions.openSession();
    try {/*ww  w.  j ava2  s. c om*/
        final Map<String, Object> result = session.selectOne(namespace + "getShortCode", sid.toString());
        if (result != null) {
            return toShortCode(result);
        } else {
            return null;
        }
    } finally {
        session.close();
    }
}

From source file:org.mobicents.servlet.restcomm.dao.mybatis.MybatisSmsMessagesDao.java

License:Open Source License

@Override
public SmsMessage getSmsMessage(final Sid sid) {
    final SqlSession session = sessions.openSession();
    try {//from   ww w  .  j  a v a 2  s.c  o m
        final Map<String, Object> result = session.selectOne(namespace + "getSmsMessage", sid.toString());
        if (result != null) {
            return toSmsMessage(result);
        } else {
            return null;
        }
    } finally {
        session.close();
    }
}

From source file:org.mobicents.servlet.restcomm.dao.mybatis.MybatisTranscriptionsDao.java

License:Open Source License

private Transcription getTranscription(final String selector, final Sid sid) {
    final SqlSession session = sessions.openSession();
    try {/*ww w . j a va  2  s  .  co m*/
        final Map<String, Object> result = session.selectOne(selector, sid.toString());
        if (result != null) {
            return toTranscription(result);
        } else {
            return null;
        }
    } finally {
        session.close();
    }
}

From source file:org.mobicents.servlet.sip.restcomm.dao.mybatis.MybatisAccountsDao.java

License:Open Source License

private Account getAccount(final String selector, final Sid sid) {
    final SqlSession session = sessions.openSession();
    try {//from  w  w w  . jav  a  2s .c  om
        final Map<String, Object> result = session.selectOne(selector, sid.toString());
        if (result != null) {
            return toAccount(result);
        } else {
            return null;
        }
    } finally {
        session.close();
    }
}

From source file:org.mobicents.servlet.sip.restcomm.dao.mybatis.MybatisApplicationsDao.java

License:Open Source License

@Override
public Application getApplication(final Sid sid) {
    final SqlSession session = sessions.openSession();
    try {// w w  w. ja v  a2  s .  c om
        final Map<String, Object> result = session.selectOne(namespace + "getApplication", sid.toString());
        if (result != null) {
            return toApplication(result);
        } else {
            return null;
        }
    } finally {
        session.close();
    }
}

From source file:org.mobicents.servlet.sip.restcomm.dao.mybatis.MybatisRegistrationsDao.java

License:Open Source License

@Override
public Registration getRegistrationByLocation(final String location) {
    final SqlSession session = sessions.openSession();
    try {/*from w  w  w.  j  a v  a  2s. c  o  m*/
        final Map<String, Object> result = session.selectOne(namespace + "getRegistrationByLocation", location);
        if (result != null) {
            return toPresenceRecord(result);
        } else {
            return null;
        }
    } finally {
        session.close();
    }
}

From source file:org.mobicents.servlet.sip.restcomm.dao.mybatis.MybatisRegistrationsDao.java

License:Open Source License

@Override
public boolean hasRegistration(final String aor) {
    final SqlSession session = sessions.openSession();
    try {//from  w  w  w.  ja  v  a2  s. co  m
        final Integer result = (Integer) session.selectOne(namespace + "hasRegistrationByAor", aor);
        return result != null && result > 0;
    } finally {
        session.close();
    }
}

From source file:org.mobicents.servlet.sip.restcomm.dao.mybatis.MybatisSandBoxesDao.java

License:Open Source License

@Override
public SandBox getSandBox(final Sid accountSid) {
    final SqlSession session = sessions.openSession();
    try {//from  w ww.j  a v a2  s  .co  m
        final Map<String, Object> result = session.selectOne(namespace + "getSandBox", accountSid.toString());
        if (result != null) {
            return toSandBox(result);
        } else {
            return null;
        }
    } finally {
        session.close();
    }
}

From source file:org.mule.module.mybatis.MyBatisConnector.java

License:CPAL v1.0

/**
 * Execute Mybatis select one function//w  w w  .  j av a  2  s  .com
 * 
 * {@sample.xml ../../../doc/mule-mybatis-module.xml.sample mybatis:select-one}
 * 
 * @param statement Fully qualified SQL statement ex: org.mybatis.example.BlogMapper.selectBlog
 * @param payload The parameter to the SQL statement
 * @return Result of MyBatis call
 * @throws IOException Io Error
 */
@Processor
public Object selectOne(String statement, @Payload Object payload) throws IOException {
    SqlSession sqlSession = createSqlSession();

    Object result = sqlSession.selectOne(statement, payload);
    closeSqlSession(sqlSession);
    return result;
}