Package com.tapestry5book.pages.chapter12

Source Code of com.tapestry5book.pages.chapter12.ShowArticlesGrid

package com.tapestry5book.pages.chapter12;

import com.tapestry5book.entities.Article;
import org.apache.tapestry5.grid.GridDataSource;
import org.apache.tapestry5.hibernate.HibernateGridDataSource;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;

import java.util.Date;
import java.util.GregorianCalendar;

public class ShowArticlesGrid {

    @Inject
    private Session session;

    public GridDataSource getArticles() {
        return new HibernateGridDataSource(session, Article.class){
            @Override
            protected void applyAdditionalConstraints(Criteria criteria) {
                Date date = new GregorianCalendar(2008, 5, 6).getTime();

                criteria.add(Restrictions.gt("publishDate", date));
            }
        };
    }
}
TOP

Related Classes of com.tapestry5book.pages.chapter12.ShowArticlesGrid

TOP
Copyright © 2018 www.massapi.com. 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.