All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.robe.admin.hibernate.dao.MenuDao Maven / Gradle / Ivy

There is a newer version: 0.5.0.0-1039
Show newest version
package io.robe.admin.hibernate.dao;

import io.robe.admin.hibernate.entity.Menu;
import io.robe.hibernate.dao.BaseDao;
import org.hibernate.Criteria;
import org.hibernate.SessionFactory;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;

import javax.inject.Inject;
import java.util.List;

public class MenuDao extends BaseDao {

    @Inject
    public MenuDao(SessionFactory sessionFactory) {
        super(sessionFactory);
    }


    public List findByModule(String names) {
        Criteria criteria = currentSession().createCriteria(Menu.class);
        criteria.add(Restrictions.eq("module", names));
        criteria.addOrder(Order.asc("index"));
        return list(criteria);
    }

    public List findHierarchicalMenu() {
        Criteria criteria = currentSession().createCriteria(Menu.class);
        criteria.add(Restrictions.isNull("parentOid"));
        criteria.addOrder(Order.asc("index"));
        return list(criteria);
    }

    public List findByParentOid(String parentOid) {
        Criteria criteria = currentSession().createCriteria(Menu.class);
        criteria.add(Restrictions.eq("parentOid", parentOid));
        criteria.addOrder(Order.asc("index"));
        return list(criteria);
    }


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy