Example usage for org.hibernate Criteria uniqueResult

List of usage examples for org.hibernate Criteria uniqueResult

Introduction

In this page you can find the example usage for org.hibernate Criteria uniqueResult.

Prototype

public Object uniqueResult() throws HibernateException;

Source Link

Document

Convenience method to return a single instance that matches the query, or null if the query returns no results.

Usage

From source file:com.aquest.emailmarketing.web.dao.BroadcastDao.java

/**
 * Gets the broadcast.//from   w  w w.  jav  a  2  s . c o  m
 *
 * @param broadcast_id the broadcast_id
 * @return the broadcast
 */
public Broadcast getBroadcast(String broadcast_id) {
    Criteria crit = session().createCriteria(Broadcast.class);
    crit.add(Restrictions.eq("broadcast_id", broadcast_id));
    return (Broadcast) crit.uniqueResult();
}

From source file:com.aquest.emailmarketing.web.dao.BroadcastDao.java

/**
 * Gets the broadcast by id.//w  w w  . j av  a  2s  . c  om
 *
 * @param id the id
 * @return the broadcast by id
 */
public Broadcast getBroadcastById(int id) {
    Criteria crit = session().createCriteria(Broadcast.class);
    crit.add(Restrictions.eq("id", id));
    return (Broadcast) crit.uniqueResult();
}

From source file:com.aquest.emailmarketing.web.dao.BroadcastDao.java

/**
 * isBroadcastExist/*from  ww w  . j  a v  a 2  s .c  om*/
 * 
 *  @param broadcast_id the broadcast_id
 *  @return true, if broadcast_id exists
 */
public boolean isBroadcastExist(String broadcast_id) {
    Criteria crit = session().createCriteria(Broadcast.class);
    crit.add(Restrictions.eq("broadcast_id", broadcast_id));
    Broadcast broadcast = (Broadcast) crit.uniqueResult();
    return broadcast != null;
}

From source file:com.aquest.emailmarketing.web.dao.BroadcastTemplateDao.java

/**
 * Gets the broadcast template./*from w ww .  j  a  v  a 2 s  .  c  om*/
 *
 * @param id the id
 * @return the broadcast template
 */
public BroadcastTemplate getBroadcastTemplate(String id) {

    Criteria crit = session().createCriteria(BroadcastTemplate.class);
    int bt_id = Integer.parseInt(id);
    crit.add(Restrictions.eq("id", bt_id));
    return (BroadcastTemplate) crit.uniqueResult();
}

From source file:com.aquest.emailmarketing.web.dao.BroadcastTemplateDao.java

/**
 * Gets the broadcast template by id.//  w  w w .j a  v a2s .  c om
 *
 * @param id the id
 * @return the broadcast template by id
 */
public BroadcastTemplate getBroadcastTemplateById(int id) {
    Criteria crit = session().createCriteria(BroadcastTemplate.class);
    crit.add(Restrictions.eq("id", id));
    return (BroadcastTemplate) crit.uniqueResult();
}

From source file:com.aquest.emailmarketing.web.dao.CampaignCategoryDao.java

/**
 * Gets the category by id./*from www  .ja  va 2s. c o m*/
 *
 * @param category_id the category_id
 * @return the category by id
 */
public CampaignCategory getCategoryById(int category_id) {
    Criteria crit = session().createCriteria(CampaignCategory.class);
    crit.add(Restrictions.eq("category_id", category_id));

    return (CampaignCategory) crit.uniqueResult();
}

From source file:com.aquest.emailmarketing.web.dao.CampaignCategoryDao.java

/**
 * Gets the category.// w  w w  . j a  v a  2s  .c om
 *
 * @param category_id the category_id
 * @return the category
 */
public CampaignCategory getCategory(int category_id) {
    Criteria crit = session().createCriteria(CampaignCategory.class);
    crit.add(Restrictions.eq("category_id", category_id));

    return (CampaignCategory) crit.uniqueResult();
}

From source file:com.aquest.emailmarketing.web.dao.CampaignsDao.java

/**
 * Gets the campaign./*ww  w. jav  a2 s  .  co  m*/
 *
 * @param campaign_id the campaign_id
 * @return the campaign
 */
public Campaigns getCampaign(String campaign_id) {
    Criteria crit = session().createCriteria(Campaigns.class);
    crit.add(Restrictions.eq("campaign_id", campaign_id));

    return (Campaigns) crit.uniqueResult();
}

From source file:com.aquest.emailmarketing.web.dao.CampaignsDao.java

/**
 * isCampaignExist// w  w w .j a  va 2s.co  m
 * 
 *  @param campaign_id the campaign_id
 *  @return true, if campaign_id exists
 */
public boolean isCampaignExist(String campaign_id) {
    Criteria crit = session().createCriteria(Campaigns.class);
    crit.add(Restrictions.eq("campaign_id", campaign_id));
    Campaigns campaigns = (Campaigns) crit.uniqueResult();
    return campaigns != null;
}