Package org.hibernate.ejb

Examples of org.hibernate.ejb.HibernateEntityManager


        return criteria.list();
    }

    @Override
    public void addTheme(YFTheme theme) {
        HibernateEntityManager hem = (HibernateEntityManager) em.getDelegate();

        if (theme.getActive()) {
            YFTheme currentTheme = this.getCurrentTheme();
            if (currentTheme != null) {
                currentTheme.setActive(false);
                hem.merge(currentTheme);
            }
        }

        hem.persist(theme);
    }
View Full Code Here


        hem.persist(theme);
    }

    @Override
    public YFTheme getCurrentTheme() {
        HibernateEntityManager hem = (HibernateEntityManager) em.getDelegate();
        Criteria criteria = hem.getSession().createCriteria(YFTheme.class);
        criteria.add(Restrictions.eq("active", true));
        try {
            return (YFTheme) criteria.uniqueResult();
        } catch (Exception e) {
            return null;
View Full Code Here

        }
    }

    @Override
    public void switchActivation(Long themeId) {
        HibernateEntityManager hem = (HibernateEntityManager) em.getDelegate();
        try {
            YFTheme theme = hem.find(YFTheme.class, themeId);
            if (theme.getActive()) {
                theme.setActive(false);
                hem.merge(theme);
            } else {
                YFTheme currentTheme = this.getCurrentTheme();
                if (currentTheme != null) {
                    currentTheme.setActive(false);
                    hem.merge(currentTheme);
                }

                theme.setActive(true);
                hem.merge(theme);
            }
        } catch (Exception e) {
        }
    }
View Full Code Here

        }
    }

    @Override
    public YFTheme get(Long themeId) {
        HibernateEntityManager hem = (HibernateEntityManager) em.getDelegate();

        YFTheme theme = hem.find(YFTheme.class, themeId);

        return theme;
    }
View Full Code Here

        return theme;
    }

    @Override
    public void update(Long themeId, String name, String description, Boolean isActive) {
        HibernateEntityManager hem = (HibernateEntityManager) em.getDelegate();
        YFTheme theme = hem.find(YFTheme.class, themeId);

        if (theme != null) {
            theme.setName(name);
            theme.setDescription(description);
            theme.setActive(isActive);

            hem.merge(theme);
        }
    }
View Full Code Here

        }
    }

    @Override
    public List<YFTheme> getMenuThemes(long menuId) {
        HibernateEntityManager hem = (HibernateEntityManager) em.getDelegate();
        Criteria criteria = hem.getSession().createCriteria(YFTheme.class);

        criteria.createAlias("menus", "m");
        criteria.add(Restrictions.eq("m.id", menuId));

        return criteria.list();
View Full Code Here

        return criteria.list();
    }

    @Override
    public List<YFTheme> getUnassignedThemesOfMenu(long menuId) {
        HibernateEntityManager hem = (HibernateEntityManager) em.getDelegate();
        Criteria criteria = hem.getSession().createCriteria(YFTheme.class);

        List<YFTheme> themes = getMenuThemes(menuId);
        if (!themes.isEmpty()) {
            ArrayList<Long> themeIds = new ArrayList<Long>();
            for (YFTheme theme : themes) {
View Full Code Here

        return criteria.list();
    }

    @Override
    public List<YFTheme> getCategoryThemes(long categoryId) {
        HibernateEntityManager hem = (HibernateEntityManager) em.getDelegate();
        Criteria criteria = hem.getSession().createCriteria(YFTheme.class);

        criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
        criteria.createAlias("categories", "c");
        criteria.add(Restrictions.eq("c.id", categoryId));
        return criteria.list();
View Full Code Here

        return criteria.list();
    }

    @Override
    public List<YFTheme> getOtherThemes(List<YFTheme> themes) {
        HibernateEntityManager hem = (HibernateEntityManager) em.getDelegate();
        Criteria criteria = hem.getSession().createCriteria(YFTheme.class);

        for (YFTheme theme : themes) {
            criteria.add(Restrictions.ne("id", theme.getId()));
        }
View Full Code Here

        return criteria.list();
    }

    @Override
    public List<YFTheme> getAssignedDishThemes(long id) {
        HibernateEntityManager hem = (HibernateEntityManager) em.getDelegate();
        Criteria criteria = hem.getSession().createCriteria(YFTheme.class);

        criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
        criteria.createAlias("dishes", "d");
        criteria.add(Restrictions.eq("d.id", id));
View Full Code Here

TOP

Related Classes of org.hibernate.ejb.HibernateEntityManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.