Example usage for org.hibernate Session getNamedQuery

List of usage examples for org.hibernate Session getNamedQuery

Introduction

In this page you can find the example usage for org.hibernate Session getNamedQuery.

Prototype

org.hibernate.Query getNamedQuery(String queryName);

Source Link

Document

Create a Query instance for the named query.

Usage

From source file:com.ibm.tap.misld.delegate.licenseAgreementType.LicenseAgreementTypeReadDelegate.java

/**
 * @param licenseAgreementTypeId/*from  w w  w.  j  a  v a 2s .c  om*/
 * @return
 * @throws NamingException
 * @throws HibernateException
 */
public static LicenseAgreementType getLicenseAgreementType(Long licenseAgreementTypeId)
        throws HibernateException, NamingException {
    Session session = getHibernateSession();
    LicenseAgreementType licenseAgreementType = (LicenseAgreementType) session
            .getNamedQuery("getLicenseAgreementTypeByLong")
            .setLong("licenseAgreementTypeId", licenseAgreementTypeId.longValue()).uniqueResult();
    session.close();

    return licenseAgreementType;
}

From source file:com.ibm.tap.misld.delegate.licenseType.LicenseTypeReadDelegate.java

/**
 * @return/*from w  w  w  . j a  v  a  2 s.c om*/
 * @throws NamingException
 * @throws HibernateException
 */
public static LicenseType getLicenseTypeByName(String licenseTypeName)
        throws HibernateException, NamingException {

    LicenseType licenseType = null;

    Session session = getHibernateSession();

    licenseType = (LicenseType) session.getNamedQuery("getLicenseTypeByName")
            .setString("licenseTypeName", licenseTypeName).uniqueResult();

    session.close();

    return licenseType;
}

From source file:com.ibm.tap.misld.delegate.licenseType.LicenseTypeReadDelegate.java

/**
 * @return//from  w w w  . j  a  v a2 s  .  c  o  m
 * @throws NamingException
 * @throws HibernateException
 */
public static List getLicenseTypes() throws HibernateException, NamingException {

    List licenseTypes = null;

    Session session = getHibernateSession();

    licenseTypes = session.getNamedQuery("getLicenseTypes").list();

    session.close();

    return licenseTypes;
}

From source file:com.ibm.tap.misld.delegate.licenseType.LicenseTypeReadDelegate.java

/**
 * @param licenseTypeId//from  w ww.ja  v a  2s  .  c  om
 * @return
 * @throws NamingException
 * @throws HibernateException
 */
public static LicenseType getLicenseType(Long licenseTypeId) throws HibernateException, NamingException {
    Session session = getHibernateSession();
    LicenseType licenseType = (LicenseType) session.getNamedQuery("getLicenseTypeById")
            .setLong("licenseTypeId", licenseTypeId.longValue()).uniqueResult();
    session.close();

    return licenseType;
}

From source file:com.ibm.tap.misld.delegate.microsoftPriceList.MicrosoftPriceListReadDelegate.java

/**
 * @param microsoftProduct/*from  w  ww. ja v a 2  s.c om*/
 * @return
 * @throws NamingException
 * @throws HibernateException
 */
public static List getMicrosoftPriceListByProduct(MicrosoftProduct microsoftProduct)
        throws HibernateException, NamingException {

    List priceList = null;

    Session session = getHibernateSession();

    priceList = session.getNamedQuery("getMicrosoftPriceListByProduct")
            .setEntity("microsoftProduct", microsoftProduct).list();

    session.close();

    return priceList;
}

From source file:com.ibm.tap.misld.delegate.microsoftPriceList.MicrosoftPriceListReadDelegate.java

/**
 * @return/*from  w w w .ja  va 2s  .  c om*/
 * @throws NamingException
 * @throws HibernateException
 */
public static List getPriceList() throws HibernateException, NamingException {
    List priceList = null;

    Session session = getHibernateSession();

    priceList = session.getNamedQuery("getMicrosoftPriceListAll").list();

    session.close();

    return priceList;
}

From source file:com.ibm.tap.misld.delegate.microsoftPriceList.MicrosoftPriceListReadDelegate.java

/**
 * @param priceListId/*w ww. j av a  2 s  .  c o m*/
 * @return
 * @throws NamingException
 * @throws HibernateException
 */
public static MicrosoftPriceList getMicrosoftPriceListById(Long priceListId)
        throws HibernateException, NamingException {

    MicrosoftPriceList microsoftPriceList = null;

    Session session = getHibernateSession();

    microsoftPriceList = (MicrosoftPriceList) session.getNamedQuery("getMicrosoftPriceListById")
            .setLong("microsoftPriceListId", priceListId.longValue()).uniqueResult();

    session.close();

    return microsoftPriceList;
}

From source file:com.ibm.tap.misld.delegate.microsoftPriceList.MicrosoftPriceListReadDelegate.java

/**
 * @param microsoftProduct//from www  .  j a  va 2 s  .  c  o m
 * @param sku
 * @param licenseAgreementType
 * @param qualifiedDiscount
 * @param licenseType
 * @param authentication
 * @param priceLevel
 * @return
 * @throws NamingException
 * @throws HibernateException
 */
public static MicrosoftPriceList getMicrosoftPriceListByFields(MicrosoftProduct microsoftProduct, String sku,
        LicenseAgreementType licenseAgreementType, QualifiedDiscount qualifiedDiscount, LicenseType licenseType,
        String authentication, PriceLevel priceLevel) throws HibernateException, NamingException {

    Session session = getHibernateSession();

    MicrosoftPriceList microsoftPriceList = (MicrosoftPriceList) session
            .getNamedQuery("getMicrosoftPriceListByFields").setEntity("microsoftProduct", microsoftProduct)
            .setString("sku", sku).setEntity("licenseAgreementType", licenseAgreementType)
            .setEntity("qualifiedDiscount", qualifiedDiscount).setEntity("priceLevel", priceLevel)
            .setEntity("licenseType", licenseType).setString("authenticated", authentication).uniqueResult();

    session.close();

    return microsoftPriceList;
}

From source file:com.ibm.tap.misld.delegate.microsoftPriceList.MicrosoftPriceListWriteDelegate.java

/**
 * @throws NamingException/*  www.  j  av a  2 s . c om*/
 * @throws HibernateException
 *  
 */
public static void clearPriceList() throws HibernateException, NamingException {

    Session session = getHibernateSession();
    Transaction tx = session.beginTransaction();

    session.delete(session.getNamedQuery("getMicrosoftPriceList").getQueryString());

    tx.commit();
    session.close();

}

From source file:com.ibm.tap.misld.delegate.microsoftPriceList.MicrosoftProductReadDelegate.java

/**
 * @param sku//from w  ww. ja va2s. c o  m
 * @param productDescription
 * @param licenseAgreementType
 * @return
 * @throws HibernateException
 * @throws NamingException
 */
public static MicrosoftProduct getMicrosoftProductByName(String productDescription)
        throws HibernateException, NamingException {

    Session session = getHibernateSession();

    MicrosoftProduct microsoftProduct = (MicrosoftProduct) session.getNamedQuery("getMicrosoftProductByName")
            .setString("productDescription", productDescription).uniqueResult();

    session.close();

    return microsoftProduct;
}