Example usage for org.hibernate Session enableFilter

List of usage examples for org.hibernate Session enableFilter

Introduction

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

Prototype

Filter enableFilter(String filterName);

Source Link

Document

Enable the named filter for this current session.

Usage

From source file:com.rapid.develop.core.jersey.features.hibernate.GenericDao.java

License:Apache License

private Session getCurrentSession() {
    Session session = hibernateSessionFactory.getSessionFactory().getCurrentSession();
    session.enableFilter("deleteFlagFilter");
    return session;
}

From source file:edu.harvard.i2b2.crc.util.HibernateUtil.java

License:Open Source License

/**
 * Function to fetch session via jboss hibernate mbean
 * Enables filter condition for delete_flag in query
 * tables/*from w  w w.ja  va 2s  . c  om*/
 * @return Session
 */
public static Session getSession() {
    Session session = null;

    InitialContext ctx;
    SessionFactory factory;

    try {
        ctx = new InitialContext();
        factory = (SessionFactory) ctx.lookup(DATASOURCE_JNDI_NAME);
        // session = factory.openSession();
        session = factory.getCurrentSession();
        session.enableFilter("deleteInstanceFlagFilter").setParameter("deleteFlagFilterParam", "N");
        session.enableFilter("deleteMasterFlagFilter").setParameter("deleteFlagFilterParam", "N");
        session.enableFilter("deleteResultInstanceFlagFilter").setParameter("deleteFlagFilterParam", "N");
    } catch (NamingException e) {
        log.error("DB Session jndi lookup[" + DATASOURCE_JNDI_NAME + "] failed", e);
        throw new ExceptionInInitializerError(e);
    }

    return session;
}

From source file:edu.purdue.cybercenter.dm.web.TermController.java

private String fetchAllTerms(HttpServletRequest request, HttpServletResponse response, boolean isTemplate) {
    Session session = DomainObjectHelper.getHbmSession();

    Filter filter = session.enableFilter("mostRecentUpdatedTermFilter");
    filter.setParameter("isTemplate", isTemplate);
    Filter assetStatusFilter = session.enableFilter("assetStatusFilter");
    assetStatusFilter.setParameterList("statusIds", Arrays.asList(1));
    String responseBody = listTerms(request, response, isTemplate ? "template" : "term");
    session.disableFilter("assetStatusFilter");
    session.disableFilter("mostRecentUpdatedTermFilter");

    return responseBody;
}

From source file:fr.hoteia.qalingo.core.dao.impl.AbstractGenericDaoImpl.java

License:Apache License

void initProductSkuFilter(Session session, Long marketAreaId, Long retailerId) {
    session.enableFilter("filterProductSkuAttributeIsGlobal");
    session.enableFilter("filterProductSkuAttributeByMarketArea").setParameter("marketAreaId", marketAreaId);

    session.enableFilter("filterProductSkuAssetIsGlobal");
    session.enableFilter("filterProductSkuAssetByMarketArea").setParameter("marketAreaId", marketAreaId);

    session.enableFilter("filterProductSkuPriceByMarketAreaAndRetailer");
    session.getEnabledFilter("filterProductSkuPriceByMarketAreaAndRetailer").setParameter("marketAreaId",
            marketAreaId);/*w w  w .  j  ava 2s .  c  o m*/
    session.getEnabledFilter("filterProductSkuPriceByMarketAreaAndRetailer").setParameter("retailerId",
            retailerId);

    session.enableFilter("filterProductSkuStockByMarketAreaAndRetailer");
    session.getEnabledFilter("filterProductSkuStockByMarketAreaAndRetailer").setParameter("marketAreaId",
            marketAreaId);
    session.getEnabledFilter("filterProductSkuStockByMarketAreaAndRetailer").setParameter("retailerId",
            retailerId);
}

From source file:fr.hoteia.qalingo.core.dao.impl.AbstractGenericDaoImpl.java

License:Apache License

void initProductMarketingFilter(Session session, Long marketAreaId, Long retailerId) {
    initProductSkuFilter(session, marketAreaId, retailerId);

    session.enableFilter("filterProductMarketingAttributeIsGlobal");
    session.enableFilter("filterProductMarketingAttributeByMarketArea").setParameter("marketAreaId",
            marketAreaId);/*from  w w  w . java  2s.  com*/

    session.enableFilter("filterProductMarketingAssetIsGlobal");
    session.enableFilter("filterProductMarketingAssetByMarketArea").setParameter("marketAreaId", marketAreaId);
}

From source file:fr.hoteia.qalingo.core.dao.impl.AbstractGenericDaoImpl.java

License:Apache License

void initCategoryVirtualFilter(Session session, Long marketAreaId, Long retailerId) {
    initProductMarketingFilter(session, marketAreaId, retailerId);

    session.enableFilter("filterCatalogVirtualCategoryAttributeIsGlobal");
    session.enableFilter("filterCatalogVirtualCategoryAttributeByMarketArea").setParameter("marketAreaId",
            marketAreaId);/*from w w w .  j  av a  2 s. co  m*/

    session.enableFilter("filterCatalogVirtualCategoryAssetIsGlobal");
    session.enableFilter("filterCatalogVirtualCategoryAssetByMarketArea").setParameter("marketAreaId",
            marketAreaId);
}

From source file:fr.hoteia.qalingo.core.dao.impl.AbstractGenericDaoImpl.java

License:Apache License

void initCategoryMasterFilter(Session session, Long marketAreaId, Long retailerId) {
    initProductMarketingFilter(session, marketAreaId, retailerId);

    session.enableFilter("filterCatalogMasterCategoryAttributeIsGlobal");
    session.enableFilter("filterCatalogMasterCategoryAttributeByMarketArea").setParameter("marketAreaId",
            marketAreaId);/*  w w w .  ja  va 2  s .co  m*/

    session.enableFilter("filterCatalogMasterCategoryAssetIsGlobal");
    session.enableFilter("filterCatalogMasterCategoryAssetByMarketArea").setParameter("marketAreaId",
            marketAreaId);
}

From source file:fr.hoteia.qalingo.core.dao.impl.AbstractGenericDaoImpl.java

License:Apache License

void initRetailerFilter(Session session, Long marketAreaId, Long retailerId) {
    initProductSkuFilter(session, marketAreaId, retailerId);

    session.enableFilter("filterRetailerAttributeIsGlobal");
    session.enableFilter("filterRetailerAttributeByMarketArea").setParameter("marketAreaId", marketAreaId);

    session.enableFilter("filterRetailerAssetIsGlobal");
    session.enableFilter("filterRetailerAssetByMarketArea").setParameter("marketAreaId", marketAreaId);
}

From source file:fr.hoteia.qalingo.core.dao.impl.ProductBrandDaoImpl.java

License:Apache License

public ProductBrand getProductBrandByCode(final Long marketAreaId, final String productBrandCode) {
    Session session = (Session) em.getDelegate();
    session.enableFilter("marketArea").setParameter("marketAreaId", marketAreaId);
    String sql = "FROM ProductBrand WHERE upper(code) = upper(:code)";
    Query query = session.createQuery(sql);
    query.setString("code", productBrandCode);
    ProductBrand productBrand = (ProductBrand) query.uniqueResult();
    return productBrand;
}

From source file:gov.nih.nci.caarray.dao.ProjectDaoImpl.java

License:BSD License

private boolean isExperimentDataModified(Project project) {
    if (project.getId() != null) {
        Session tempSession = getHibernateHelper().getSessionFactory().openSession();
        try {//w w w.  j ava2s . c  om
            tempSession.enableFilter(Experiment.BIOMATERIAL_FILTER_NAME);
            Project prePersistPrj = (Project) tempSession.load(Project.class, project.getId());
            return samplesChanged(prePersistPrj, project);
        } finally {
            tempSession.close();
        }
    } else {
        return true;
    }
}