Example usage for org.hibernate Criteria setFetchMode

List of usage examples for org.hibernate Criteria setFetchMode

Introduction

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

Prototype

public Criteria setFetchMode(String associationPath, FetchMode mode) throws HibernateException;

Source Link

Document

Specify an association fetching strategy for an association or a collection of values.

Usage

From source file:org.hoteia.qalingo.core.dao.CatalogDao.java

License:Apache License

public CatalogVirtual getVirtualCatalogByMarketAreaId(final Long marketAreaId, Object... params) {
    Criteria criteria = createDefaultCriteria(CatalogVirtual.class);

    FetchPlan fetchPlan = handleSpecificFetchMode(criteria, params);

    criteria.setFetchMode("catalogMaster", FetchMode.JOIN);
    criteria.createAlias("marketArea", "marketArea", JoinType.LEFT_OUTER_JOIN);
    criteria.add(Restrictions.eq("marketArea.id", marketAreaId));

    CatalogVirtual catalogVirtual = (CatalogVirtual) criteria.uniqueResult();
    if (catalogVirtual != null) {
        catalogVirtual.setFetchPlan(fetchPlan);
    }//w w w. j  a va 2 s  .  c  o m
    return catalogVirtual;
}

From source file:org.hoteia.qalingo.core.dao.impl.CartDaoImpl.java

License:Apache License

private void addDefaultFetch(Criteria criteria) {
    criteria.setFetchMode("session", FetchMode.JOIN);
    criteria.setFetchMode("cartItems", FetchMode.JOIN);

    criteria.createAlias("cartItems.productSku.productSkuAttributes", "productSkuAttributes",
            JoinType.LEFT_OUTER_JOIN);/*from w ww .  j a v a  2  s . c om*/
    criteria.setFetchMode("productSkuAttributes", FetchMode.JOIN);

    criteria.createAlias("cartItems.productSku.assets", "productSkuAssets", JoinType.LEFT_OUTER_JOIN);
    criteria.setFetchMode("productSkuAssets", FetchMode.JOIN);

    criteria.createAlias("cartItems.productSku.prices", "productSkuPrices", JoinType.LEFT_OUTER_JOIN);
    criteria.setFetchMode("productSkuPrices", FetchMode.JOIN);

    criteria.createAlias("cartItems.productSku.stocks", "productSkuStocks", JoinType.LEFT_OUTER_JOIN);
    criteria.setFetchMode("productSkuStocks", FetchMode.JOIN);

    criteria.createAlias("cartItems.productMarketing", "productMarketing", JoinType.LEFT_OUTER_JOIN);
    criteria.setFetchMode("productMarketing", FetchMode.JOIN);

    criteria.createAlias("cartItems.productMarketing.productMarketingAttributes", "productMarketingAttributes",
            JoinType.LEFT_OUTER_JOIN);
    criteria.setFetchMode("productMarketingAttributes", FetchMode.JOIN);

    criteria.createAlias("cartItems.productMarketing.assets", "productMarketingAssets",
            JoinType.LEFT_OUTER_JOIN);
    criteria.setFetchMode("productMarketingAssets", FetchMode.JOIN);

    criteria.createAlias("cartItems.catalogCategory.catalogCategoryAttributes", "catalogCategoryAttributes",
            JoinType.LEFT_OUTER_JOIN);
    criteria.setFetchMode("catalogCategoryAttributes", FetchMode.JOIN);

    criteria.createAlias("cartItems.catalogCategory.assets", "catalogCategoryAssets", JoinType.LEFT_OUTER_JOIN);
    criteria.setFetchMode("catalogCategoryAssets", FetchMode.JOIN);

    criteria.setFetchMode("shippings", FetchMode.JOIN);
}

From source file:org.hoteia.qalingo.core.dao.impl.CatalogCategoryDaoImpl.java

License:Apache License

private void addDefaultCatalogCategoryFetch(Criteria criteria) {

    criteria.setFetchMode("categoryMaster", FetchMode.JOIN);

    criteria.setFetchMode("defaultParentCatalogCategory", FetchMode.JOIN);

    criteria.setFetchMode("catalogCategoryAttributes", FetchMode.JOIN);

    criteria.setFetchMode("catalogCategories", FetchMode.JOIN);

    criteria.createAlias("catalogCategories.catalogCategoryAttributes", "catalogSubCategoryAttributes",
            JoinType.LEFT_OUTER_JOIN);/*from w w  w .j av a  2s  .c  om*/
    criteria.setFetchMode("catalogSubCategoryAttributes", FetchMode.JOIN);

    criteria.setFetchMode("productMarketings", FetchMode.JOIN);

    criteria.createAlias("productMarketings.productMarketingAttributes", "productMarketingAttributes",
            JoinType.LEFT_OUTER_JOIN);
    criteria.setFetchMode("productMarketingAttributes", FetchMode.JOIN);

    criteria.setFetchMode("assets", FetchMode.JOIN);

}

From source file:org.hoteia.qalingo.core.dao.impl.CatalogDaoImpl.java

License:Apache License

public CatalogVirtual getVirtualCatalogByMarketAreaId(final Long marketAreaId) {
    Criteria criteria = createDefaultCriteria(CatalogVirtual.class);
    addDefaultCatalogFetch(criteria);/*  w w w  . j  a v  a  2 s .c om*/
    criteria.setFetchMode("catalogMaster", FetchMode.JOIN);
    criteria.createAlias("marketArea", "ma", JoinType.LEFT_OUTER_JOIN);
    criteria.add(Restrictions.eq("ma.id", marketAreaId));

    CatalogVirtual catalogVirtual = (CatalogVirtual) criteria.uniqueResult();
    return catalogVirtual;
}

From source file:org.hoteia.qalingo.core.dao.impl.CatalogDaoImpl.java

License:Apache License

private void addDefaultCatalogFetch(Criteria criteria) {

    criteria.setFetchMode("catalogCategories", FetchMode.JOIN);

    criteria.createAlias("catalogCategories.catalogCategoryAttributes", "catalogCategoryAttributes",
            JoinType.LEFT_OUTER_JOIN);//  w ww  .  j  a v a2  s.  co  m
    criteria.setFetchMode("catalogCategoryAttributes", FetchMode.JOIN);

}

From source file:org.hoteia.qalingo.core.dao.impl.CustomerDaoImpl.java

License:Apache License

private void addDefaultFetch(Criteria criteria) {
    criteria.setFetchMode("credentials", FetchMode.JOIN);
    criteria.setFetchMode("addresses", FetchMode.JOIN);
    criteria.setFetchMode("connectionLogs", FetchMode.JOIN);

    criteria.setFetchMode("customerMarketAreas", FetchMode.JOIN);

    criteria.createAlias("customerMarketAreas.optins", "optins", JoinType.LEFT_OUTER_JOIN);
    criteria.setFetchMode("optins", FetchMode.JOIN);

    criteria.createAlias("customerMarketAreas.wishlistProducts", "wishlistProducts", JoinType.LEFT_OUTER_JOIN);
    criteria.setFetchMode("wishlistProducts", FetchMode.JOIN);

    criteria.createAlias("customerMarketAreas.productComments", "productComments", JoinType.LEFT_OUTER_JOIN);
    criteria.setFetchMode("productComments", FetchMode.JOIN);

    criteria.setFetchMode("customerAttributes", FetchMode.JOIN);
    criteria.setFetchMode("customerGroups", FetchMode.JOIN);
    criteria.setFetchMode("oauthAccesses", FetchMode.JOIN);
    criteria.setFetchMode("customerOrderAudit", FetchMode.JOIN);
}

From source file:org.hoteia.qalingo.core.dao.impl.DeliveryMethodDaoImpl.java

License:Apache License

private void addDefaultFetch(Criteria criteria) {
    criteria.setFetchMode("deliveryMethodCountries", FetchMode.JOIN);
    criteria.setFetchMode("prices", FetchMode.JOIN);

    criteria.createAlias("prices.currency", "currency", JoinType.LEFT_OUTER_JOIN);
    criteria.setFetchMode("currency", FetchMode.JOIN);

}

From source file:org.hoteia.qalingo.core.dao.impl.EngineSettingDaoImpl.java

License:Apache License

private void addDefaultFetch(Criteria criteria) {
    criteria.setFetchMode("engineSettingValues", FetchMode.JOIN);
}

From source file:org.hoteia.qalingo.core.dao.impl.GroupRoleDaoImpl.java

License:Apache License

private void addDefaultFetch(Criteria criteria) {
    criteria.setFetchMode("customerRoles", FetchMode.JOIN);
}

From source file:org.hoteia.qalingo.core.dao.impl.MarketDaoImpl.java

License:Apache License

private void addDefaultMarketPlaceFetch(Criteria criteria) {
    //      ProjectionList projections = Projections.projectionList();
    //      criteria.setProjection(projections);

    criteria.setFetchMode("masterCatalog", FetchMode.JOIN);
    criteria.setFetchMode("markets", FetchMode.JOIN);
    criteria.setFetchMode("marketPlaceAttributes", FetchMode.JOIN);

    //      criteria.createAlias("markets.marketAreas", "marketAreas", JoinType.LEFT_OUTER_JOIN);
    //      criteria.setFetchMode("markets.marketAreas", FetchMode.JOIN);

    //      criteria.createAlias("markets.marketAreas.defaultLocalization", "defaultLocalization", JoinType.LEFT_OUTER_JOIN);
    //      criteria.setFetchMode("defaultLocalization", FetchMode.JOIN);
    //// w  ww  . j ava2  s .  com
    //      projections.add(Projections.property("markets.marketAreas.defaultLocalization"));
    //
    //      criteria.createAlias("markets.marketAreas.localizations", "localizations", JoinType.LEFT_OUTER_JOIN);
    //      criteria.setFetchMode("localizations", FetchMode.JOIN);
    //
    //      projections.add(Projections.property("markets.marketAreas.localizations"));
    //
    //      criteria.createAlias("markets.marketAreas.retailers", "retailers", JoinType.LEFT_OUTER_JOIN);
    //      criteria.setFetchMode("retailers", FetchMode.JOIN);
    //      
    //      projections.add(Projections.property("markets.marketAreas.retailers"));
    //      
    //      criteria.createAlias("markets.marketAreas.marketAreaAttributes", "marketAreaAttributes", JoinType.LEFT_OUTER_JOIN);
    //      criteria.setFetchMode("marketAreaAttributes", FetchMode.JOIN);
    //      
    //      projections.add(Projections.property("markets.marketAreas.marketAreaAttributes"));
}