This is my code in Hibernate returning LIST...

Hibernate DAO

public class TbCommandDAO {

    protected Session session;
    protected Transaction tx = null;

    public TbCommandDAO() {
        SessionFactory factory = HibernateUtil.getSessionFactory();
        this.session = factory.getCurrentSession();
    }

    public List<TbCommand> getList(){

        try {
            tx = session.beginTransaction();
            Criteria crit = session.createCriteria(TbCommand.class);
            List<TbCommand> results = (List<TbCommand>) crit.list();
            
            tx.commit();
            return results;
        }catch (HibernateException e) {
            if (session.getTransaction().isActive()) {
                session.getTransaction().rollback();
            }

            if (tx != null){
                tx.rollback();
            }
            return null;
        }finally {
            tx = null;
        }
    }
}


Page Class

private TbCommandDAO tbcommanddao;

public List<TbCommand> getList(){

        if(tbcommanddao == null)
        tbcommanddao = new TbCommandDAO();

        List<TbCommand> result = (List<TbCommand>) tbcommanddao.getList();
        return result;
 }


Hope it can help you...
-- 
View this message in context: 
http://tapestry.1045711.n5.nabble.com/Early-steps-getting-Tapestry-and-Hibernate-working-via-DAO-tp3072498p3203901.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to