Menu

For large Database Primefaces CRUD Generated Application gets hang up

Anonymous
2013-07-11
2013-07-26
  • Anonymous

    Anonymous - 2013-07-11

    I used to test large employee database (
    http://dev.mysql.com/doc/employee/en/index.html ) which contains 2 million rows. For small data, Primefaces CRUD Generated Application datatable works fine. If we select large data, the UI JSF application gets hangup. For more information i used nbpfcrudgen-0.15-7.3, Can anyone please test this above case.

     
  • Kay Wrobel

    Kay Wrobel - 2013-07-11

    So let me, without being too smart about it, say this: the CRUD generator is not going to eliminate programming and customization. The idea was to take the original JSF pages generator and update it with PrimeFaces tech. You still need to go ahead and customize your application. Now, it is clear with large data sets that you have to come up with a different solution. That is why PrimeFaces supports Lazy Loading. But lazy loading requires a bit more hand holding than what can be accomplished by a code generator. In this particular case, we're also dealing with an AbstractController class that is intentionally kept as generic as possible which is, again, in line with what NetBeans does with it's generator.

    Sorry, I know I didn't answer your question. Maybe you didn't want to hear that. For your particular project, I'd look at Lazy Loading and see if you can tweak the code generated so that the back end doesn't have to return all 2M rows. Maybe in your design, you would want to add a search criteria first before diving into the data. Right? I mean, you wouldn't walk into a library and look through every book on the shelves to find what you're looking for . You'd probably have some kind of search criteria to narrow down that list of books to look at. (I know I'm being vague here). I guess what I'm saying is, use this tool as a starting point and customize and enhance later.

     
  • Anonymous

    Anonymous - 2013-07-22

    Hi can you give some sample working datable lazy load integration with primefaces crud generator.

     
  • Anonymous

    Anonymous - 2013-07-22

    Hi , tried primefaces lazy loading datable with primefaces crud generator, but i didn't get the idea and integration flow. I followed an example (http://www.simtay.com/part-4-lazy-loading-and-pagination-with-jsf-2-1-primefaces-3-5-datatable-and-form-validation/)

    List.xhtml

    p:dataTable id="datalist" value="#{departmentsController.lazyDepartmentItems}" var="item"
    selectionMode="single" selection="#{departmentsController.selected}"
    rowKey="#{item.deptNo}"
    paginator="true"
    rows="10"
    rowsPerPageTemplate="10,20,30"

    AbstractController.java

    public List<t> getLazyDepartmentItems() {
    if (lazyDepartmentItems == null) {
    lazyDepartmentItems = this.ejbFacade.findWithNamedQuery(null, start, end);
    }
    return items;
    }</t>

    AbstractFacade.java

    /*
    * Returns the number of records that will be used with lazy loading / pagination
    * @param namedQueryName
    * @param start
    * @param end
    * @return List
    /
    public List findWithNamedQuery(String namedQueryName, int start, int end) {
    javax.persistence.criteria.CriteriaQuery cq = getEntityManager().getCriteriaBuilder().createQuery();
    cq.select(cq.from(entityClass));
    return getEntityManager().createQuery(cq).getResultList();
    Query query = this.em.createNamedQuery(namedQueryName);
    query.setMaxResults(end - start);
    query.setFirstResult(start);
    return query.getResultList();
    }

    Departments.java

    @Entity
    @Table(name = "departments", catalog = "employees", schema = "")
    @XmlRootElement
    @NamedQueries({
    //for lazy loading

    @NamedQuery(name = "Departments.countDepartmentsTotal", query = "SELECT COUNT(d) FROM Departments d"),
    //
    @NamedQuery(name = "Departments.findAll", query = "SELECT d FROM Departments d"),
    @NamedQuery(name = "Departments.findByDeptNo", query = "SELECT d FROM Departments d WHERE d.deptNo = :deptNo"),
    @NamedQuery(name = "Departments.findByDeptName", query = "SELECT d FROM Departments d WHERE d.deptName = :deptName")})
    

    public class Departments implements Serializable {

     

Anonymous
Anonymous

Add attachments
Cancel