@@ -0,0 +1,1584 @@
+package wissolsoft.porada.webapp.dao;%0A%0Aimport java.util.List;%0A%0Aimport org.hibernate.Criteria;%0Aimport org.hibernate.Session;%0Aimport org.hibernate.SessionFactory;%0Aimport org.hibernate.criterion.Restrictions;%0Aimport org.springframework.beans.factory.annotation.Autowired;%0Aimport org.springframework.stereotype.Repository;%0Aimport org.springframework.transaction.annotation.Transactional;%0A%0Aimport wissolsoft.porada.webapp.model.Deputy;%0A%0A@Repository%0Apublic class DeputyDao %7B%0A%0A    @Autowired(required = true)%0A    private SessionFactory sessionFactory;%0A%0A    public Session getSession() %7B%0A        Session sess;%0A        try %7B%0A            sess = sessionFactory.getCurrentSession();%0A        %7D catch (Exception e) %7B%0A            sess = sessionFactory.openSession();%0A        %7D%0A        return sess;%0A    %7D%0A%0A    @Transactional%0A    public void insertDeputy(final Deputy deputy) %7B%0A        final Session session = getSession();%0A        session.save(deputy);%0A        session.flush();%0A    %7D%0A%0A    @Transactional%0A    public List%3CDeputy%3E getAllDeputies() %7B%0A        final Session session = getSession();%0A        final Criteria criteria = session.createCriteria(Deputy.class);%0A        final List%3CDeputy%3E deputies = criteria.list();%0A        return deputies;%0A    %7D%0A%0A    @Transactional%0A    public Deputy getByShortName(String shortName) %7B%0A        final Session session = getSession();%0A        final Criteria criteria = session.createCriteria(Deputy.class);%0A        criteria.add(Restrictions.eq(%22shortname%22, shortName));%0A        final Deputy deputy = (Deputy)criteria.uniqueResult();%0A        return deputy;%0A    %7D%0A%0A%7D%0A

Add Deputy DAO