4 Replies Latest reply on Mar 20, 2009 1:47 AM by Pucky Loucks

    trying to understand s:link and queries firing on following pages

    Pucky Loucks Newbie

      I've got a large application that I'm starting to see having a decrease in performance and I'm starting to think I have missed something basic with regards to s:link (or something else)


      I have a page that has a link in the menu that does the following



      <li>
        <s:link value="Family Search" view="/executive/enrollment/familySearch.xhtml" propagation="none">
          <f:param name="organizationOrganizationid" value="#{extranetSession.organization.organizationid}"/>
          <f:param name="programId" value="#{extranetSession.program.id}"/>
          <f:param name="enrollmentYearEnrollmentyearid" value="#{extranetSession.enrollmentyear.enrollmentyearid}"/>
        </s:link>
      </li>



      The Problem is that when I hit the main page (which is just a page with a logo and links along the side (i.e. menu) the SQL for the familySearch.xhtml page fires. 


      Why is this?  What should I do so that it doesn't happen?  The problem also happens when I search on the family search page,  The Results contain a link to view FamilyDetails and the database fires a DEEP SQL select statement for each result that is coming back, even though I haven't called a property from a DEEP object of the family. 


      Hope someone can help me out as this is getting confusing trying to understand it.


      Thanks,


        • 1. Re: trying to understand s:link and queries firing on following pages
          Adrien Orsier Newbie

          Hmm what do you mean exactly by SQL for the familySearch.xhtml?
          I think we'd need some code here, since s:link won't process familySearch.xhtml code here.


          You're refering to a Component, extranetSession. Isn't that component auto-processing some code, like in an @Create method for example?

          • 2. Re: trying to understand s:link and queries firing on following pages
            Marcio Endo Newbie

            Make sure you are not running in debug mode.


            Check your component.properties files.

            • 3. Re: trying to understand s:link and queries firing on following pages
              Pucky Loucks Newbie

              Adrien Orsier wrote on Mar 19, 2009 11:57:


              Hmm what do you mean exactly by SQL for the familySearch.xhtml?
              I think we'd need some code here, since s:link won't process familySearch.xhtml code here.


              It's hard to know how much to put in a post to get my point across. ;) 


              When the user logs into the system they end up on home.xhtml which has a menu on the left and a drop down on the right with a listing of organizations.


              The idea of the drop down is to add the organization that the user selects to the extranetSession so that it can be used in the where clause of any and all SQL queries.  (more or less acts as a filter for them)


              I currently have enabled hibernate to show sql as I was wanting to see what is going on due to the performance loss.


              So my confusion is why would the FamilySearchList.java logic fire and hence hibernate print to the log file when the user lands on home.xhtml. (even before the system adds something to the extranetSession object) 




              extranetSessionBean.java


              ...
              
              @Stateful
              @Name("extranetSession")
              @Scope(ScopeType.SESSION)
              public class ExtranetSessionBean implements ExtranetSession,Serializable {
                   
                   /**
                    * 
                    */
                   private static final long serialVersionUID = 5495049614491250757L;
                   
                   @In private Conversation conversation; 
              
                   
                   private Organization organization = new Organization();
              
                   private EnrollmentYear enrollmentyear = new EnrollmentYear();
              
                   private Program program = new Program();
                   
                   @PersistenceContext(type=PersistenceContextType.EXTENDED)
                  private transient EntityManager em;
                   
                   private Integer firstResult;
                   
                   private ConsultantEnrollment consultantEnrollment = new ConsultantEnrollment();
                   
                   private List<Long> consultantEnrollmentIdList = new ArrayList<Long>(0);
                   
                   private List<Long> learnerEnrollmentIdList = new ArrayList<Long>(0);
                   
                   private int conid;
                   
                   private int leaid;
                   
                   private Date serverDate;
                   
                   private String fromPage;
              
                  @Logger private transient Log log;
              
                   /* (non-Javadoc)
                    * @see com.selfdesign.sdlcextranet.session.ExtranetSession#getOrganization()
                    */
                   public Organization getOrganization() {
                        return organization;
                   }
              
                   /* (non-Javadoc)
                    * @see com.selfdesign.sdlcextranet.session.ExtranetSession#setOrganization(com.selfdesign.sdlcextranet.entity.Organization)
                    */
                   public void setOrganization(Organization organization) {
                        this.organization = organization;
                   }
                   
                   public boolean ready(){
                        boolean result = false;
                        if(this.organization.getOrganizationid()!=null && this.enrollmentyear.getEnrollmentyearid()!=null){
                             result = true;
                        }
                        return result;
                   }
                   
                   @Destroy
                   @Remove
                   public void cleanup()
                   {
                        
                   }
              
                   public EnrollmentYear getEnrollmentyear() {
                        return enrollmentyear;
                   }
              
                   public void setEnrollmentyear(EnrollmentYear enrollmentyear) {
                        this.enrollmentyear = enrollmentyear;
                   }
              
                   public String extranetSession(String _organizationName, String _enrollmentYearName){
                        
              
                        
                        Organization org = null;
                        
                        Query organizationQuery = em.createNamedQuery("findOrganization").setParameter("name", _organizationName);
                        org = (Organization)organizationQuery.getSingleResult();
                        
                        EnrollmentYear year = null;
                        
                        Iterator<EnrollmentYear> yearlist = org.getEnrollmentYearList().iterator();
                        
                        while(yearlist.hasNext()){
                             EnrollmentYear tempyear = yearlist.next();
                             if(tempyear.getName().equalsIgnoreCase(_enrollmentYearName)){
                                  year = tempyear;
                                  break;
                             }
                        }
                        
                        setOrganization(org);
                        setEnrollmentyear(year);
                        
                        return "done";
                   }
                   
                   public String extranetSession(String _organizationName, String _program, String _enrollmentYearName){
                        
                        
                        Organization org = null;
                        
                        Query organizationQuery = em.createNamedQuery("findOrganization").setParameter("name", _organizationName);
                        org = (Organization)organizationQuery.getSingleResult();
                        
                        Iterator<Program > programList = org.getProgramList().iterator();
                        
                        while(programList.hasNext()){
                             Program tempprogram = programList.next();
                             if(tempprogram.getName().equalsIgnoreCase(_program)){
                                  this.program = tempprogram;
                                  break;
                             }
                             
                        }
                        
                        
                        EnrollmentYear year = null;
                        
                        Iterator<EnrollmentYear> yearlist = org.getEnrollmentYearList().iterator();
                        
                        while(yearlist.hasNext()){
                             EnrollmentYear tempyear = yearlist.next();
                             if(tempyear.getName().equalsIgnoreCase(_enrollmentYearName)){
                                  year = tempyear;
                                  break;
                             }
                        }
                        
                        setOrganization(org);
                        setEnrollmentyear(year);
                        
                        return "done";
                        
                   }
              
                   public Program getProgram() {
                        return program;
                   }
              
                   public void setProgram(Program program) {
                        this.program = program;
                   }
              
                   public Integer getFirstResult() {
                        return firstResult;
                   }
              
                   public void setFirstResult(Integer firstResult) {
                        this.firstResult = firstResult;
                   }
              
                   public ConsultantEnrollment getConsultantEnrollment() {
                        return consultantEnrollment;
                   }
              
                   public void setConsultantEnrollment(ConsultantEnrollment consultantEnrollment) {
                        this.consultantEnrollment = consultantEnrollment;
                   }
              
              
                   
                   public List<Long> getConsultantEnrollmentIdList()
                   {
                        return consultantEnrollmentIdList;
                   }
              
                   public void setConsultantEnrollmentIdList(List<Long> consultantEnrollmentIdList)
                   {
                        this.consultantEnrollmentIdList = consultantEnrollmentIdList;
                   }
              
                   public List<Long> getLearnerEnrollmentIdList()
                   {
                        return learnerEnrollmentIdList;
                   }
              
                   public void setLearnerEnrollmentIdList(List<Long> learnerEnrollmentIdList)
                   {
                        this.learnerEnrollmentIdList = learnerEnrollmentIdList;
                   }
              
                   public void addConsultantEnrollmentId(Long consultantEnrollmentId){
                        
                        if(!consultantEnrollmentIdList.contains(consultantEnrollmentId)){
                             consultantEnrollmentIdList.add(consultantEnrollmentId);
                        }
                        
                   }
              
                   public void addLearnerEnrollmentId(Long learnerEnrollmentId){
                        
                        if(!learnerEnrollmentIdList.contains(learnerEnrollmentId)){
                             learnerEnrollmentIdList.add(learnerEnrollmentId);
                        }
                        
                   }
              
                   public int getConid()
                   {
                        return conid;
                   }
              
                   public void setConid(int conid)
                   {
                        this.conid = conid;
                   }
              
                   public int getLeaid()
                   {
                        return leaid;
                   }
              
                   public void setLeaid(int leaid)
                   {
                        this.leaid = leaid;
                   }
                   
                   
                   public void keepAlive(){
                        setServerDate(new Date());
              
                        //log.info("#{identity.username} is logged in with cid #{conversation.id} on view id #{conversation.viewId} the conversation timeout is #{conversation.timeout}: longrunning = #{conversation.longRunning}: isNested = #{conversation.nested}}"); 
                        
                             
                        
                        if(conversation.isLongRunning()){
                             conversation.begin(true, false);
                        }
              
                   }
                   
                   public void keepAlive(Long cid){
                        setServerDate(new Date());
                        log.info("passed id: #0",cid.toString());
                        log.info("#{identity.username} is logged in with cid #{conversation.id} on view id #{conversation.viewId} the conversation timeout is #{conversation.timeout}: longrunning = #{conversation.longRunning}: isNested = #{conversation.nested}}"); 
                        
                             
                        
                        if(conversation.isLongRunning()){
                             conversation.begin(true, false);
                        }
              
                   }
              
                   public Date getServerDate()
                   {
                        return serverDate;
                   }
              
                   public void setServerDate(Date serverDate)
                   {
                        this.serverDate = null;
                        this.serverDate = serverDate;
                   }
              
                   public String getFromPage() {
                        return fromPage;
                   }
              
                   public void setFromPage(String fromPage) {
                        this.fromPage = fromPage;
                   }
                   
              }
              
              




              persistence.xml


              ...         
              <property name="hibernate.show_sql" value="true"/>
              ...
              





              familySearch.page.xml




              <?xml version="1.0" encoding="UTF-8"?>
              <page xmlns="http://jboss.com/products/seam/pages"
                    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                    xsi:schemaLocation="http://jboss.com/products/seam/pages http://jboss.com/products/seam/pages-2.0.xsd">
                     
                   <param name="programId" value="#{familySearchList.program.id}"/>
                   <param name="organizationOrganizationid" value="#{familySearchList.organization.organizationid}"/>
                   <param name="enrollmentYearEnrollmentyearid" value="#{familySearchList.enrollmentYear.enrollmentyearid}"/>
                   <param name="organizationName" value="#{familySearchList.organization.name}"/>
                   <action execute="#{familySearchList.setMaxResults(25)}"/>
                   <param name="firstResult" value="#{familySearchList.firstResult}"/>
                   <param name="order" value="#{familySearchList.order}"/>
                   <param name="from"/>
                   
                   <param name="parentParentId" value="#{familySearchList.parent.id}"/>
                   <param name="parentfirstname" value="#{familySearchList.parent.firstname}"/>
                   <param name="parentlastname" value="#{familySearchList.parent.lastname}"/>
                   
                   <param name="learnerLearnerId" value="#{familySearchList.learner.id}"/>
                   <param name="learnerfirstname" value="#{familySearchList.learner.firstname}"/>
                   <param name="learnerlastname" value="#{familySearchList.learner.lastname}"/>
                   <param name="giftedprogram" value="#{familySearchList.learner.giftedprogram}"/>
                   <param name="firstnation" value="#{familySearchList.learner.firstnations}"/>
                   <param name="specialedgrant" value="#{familySearchList.specialed.specialedgrant}"/>
                   <param name="highincidence" value="#{familySearchList.specialed.highincidence}"/>
                   <param name="familyFamilyid" value="#{familySearchList.family.familyid}"/>
                   <param name="legacyfamilyid" value="#{familySearchList.family.legacyfamilyid}"/>
                   <param name="isk" value="#{familySearchList.learnerEnrollment.isk}"/>
                   
                   <action execute="#{extranetSession.setFirstResult(familySearchList.firstResult)}"/>
                   <action execute="#{extranetSession.ready()}"/>
                   
                   <navigation from-action="#{extranetSession.ready()}">
                        <rule if-outcome="false">
                             <redirect view-id="/errors/organizationException.xhtml"></redirect>
                        </rule>
                   </navigation>
                   
              </page>
              


              familySearch.xhtml


              <h:form id="search">
                             <div id="family" class="name">
                                  <h4>Family Info</h4>
                                  <label>Family Id:</label>
                                  <h:inputText id="familyid" value="#{familySearchList.family.familyid}" styleClass="number" />
                                  <br/>
                                  <label>Legacy Id:</label>
                                  <h:inputText id="legacyfamilyid" value="#{familySearchList.family.legacyfamilyid}" styleClass="number" />
                             </div>
                             <div id="parent" class="name">
                                  <h4>Parent's Name</h4>
                                  <label>Parent ID</label>
                                  <h:inputText id="parentParentId" value="#{familySearchList.parent.id}" />
                                  <label>Firstname</label>
                                  <h:inputText id="parentfirstname" value="#{familySearchList.parent.firstname}" />
                                  <label>Lastname</label>
                                  <h:inputText id="parentlastname" value="#{familySearchList.parent.lastname}" />
                             </div>
                             <div id="learner" class="name">
                                  <h4>Learner's Name</h4>
                                  <label>Learner ID</label>
                                  <h:inputText id="learnerLearnerId" value="#{familySearchList.learner.id}" />
                                  <label>Firstname</label>
                                  <h:inputText id="learnerfirstname" value="#{familySearchList.learner.firstname}" />
                                  <label>Lastname</label>
                                  <h:inputText id="learnerlastname" value="#{familySearchList.learner.lastname}" />
                             </div>
                             <ul id="flags">
                                  <li>
                                       <h:selectBooleanCheckbox id="highincidence" value="#{familySearchList.specialed.highincidence}"/>
                                       <label>High Incidence?</label>
                                  </li>
                                  <li>
                                       <h:selectBooleanCheckbox id="specialedgrant" value="#{familySearchList.specialed.specialedgrant}"/>
                                       <label>Special Ed Grant?</label>
                                  </li>
                                  <li>
                                       <h:selectBooleanCheckbox id="firstnation" value="#{familySearchList.learner.firstnations}"/>
                                       <label>First Nation?</label>
                                  </li>
                                  <li>
                                       <h:selectBooleanCheckbox id="giftedprogram" value="#{familySearchList.learner.giftedprogram}"/>
                                       <label>Gifted Program?</label>
                                  </li>
                                  <li>
                                       <h:selectBooleanCheckbox id="isk" value="#{familySearchList.learnerEnrollment.isk}" />
                                       <label>ISK</label>
                                  </li>
                             </ul>
                             <div id="actions">
                                  <h:commandButton id="search" value="Search" action="/executive/enrollment/familySearch.xhtml">
                                       <f:param name="organizationOrganizationid" value="#{extranetSession.organization.organizationid}"/>
                                       <f:param name="programId" value="#{extranetSession.program.id}"/>
                                       <f:param name="enrollmentYearEnrollmentyearid" value="#{extranetSession.enrollmentyear.enrollmentyearid}"/>
                                  </h:commandButton>
                                  &#160;&#160;|&#160;&#160;
                                  <h:commandButton action="/executive/enrollment/familyDetails.xhtml" value="Create Family" />
                             </div>
                        </h:form>
                        <div id="results">
                             <s:div rendered="#{not empty familySearchList.resultList}">
                                  <h3>Search Results :: Found #{familySearchList.resultCount} records</h3>
                             </s:div>
                             <h:outputText  value="The search returned no results." rendered="#{empty familySearchList.resultList}"/>
                             <div class="controls">
                                  <s:button view="/executive/enrollment/familySearch.xhtml" value="&#60;&#60; First" id="tfirstPage" disabled="#{familySearchList.dataModelSelectionIndex ge 0 and familySearchList.previousExists ? 'false' : 'true'}">
                                       <f:param name="firstResult" value="0"/>
                                  </s:button>
                                  <s:button view="/executive/enrollment/familySearch.xhtml" value="&#60; Previous" id="tpreviousPage" disabled="#{familySearchList.dataModelSelectionIndex ge 0 and familySearchList.previousExists ? 'false' : 'true'}">
                                       <f:param name="firstResult" value="#{familySearchList.previousFirstResult}"/>
                                  </s:button>
                                  <s:button view="/executive/enrollment/familySearch.xhtml" value="Next &#62;" id="tnextPage" disabled="#{familySearchList.dataModelSelectionIndex le familySearchList.lastFirstResult and familySearchList.nextExists ? 'false' : 'true'}">
                                       <f:param name="firstResult" value="#{familySearchList.nextFirstResult}"/>
                                  </s:button>
                                  <s:button view="/executive/enrollment/familySearch.xhtml" value="Last &#62;&#62;" id="tlastPage" disabled="#{familySearchList.dataModelSelectionIndex le familySearchList.lastFirstResult and familySearchList.nextExists ? 'false' : 'true'}">
                                       <f:param name="firstResult" value="#{familySearchList.lastFirstResult}"/>
                                  </s:button>
                             </div>
                             <rich:dataTable id="parentList" var="family" value="#{familySearchList.resultList}" rendered="#{not empty familySearchList.resultList}">
                                  <rich:column>
                                       <f:facet name="header">Fam.ID</f:facet>
                                       <s:link id="family" value="#{family.familyid}" propagation="join" view="/executive/enrollment/familyDetails.xhtml">
                                            <f:param name="familyFamilyid" value="#{family.familyid}"/>
                                       </s:link>
                                  </rich:column>
                                  <rich:column>
                                       <f:facet name="header">LegacyID</f:facet>
                                       <s:fragment rendered="#{not empty family.legacyfamilyid}">#{family.legacyfamilyid}</s:fragment>
                                  </rich:column>
                                  <rich:column>
                                       <f:facet name="header">Return?</f:facet>
                                       <s:div rendered="#{not empty family.legacyfamilyid}">YES</s:div>
                                  </rich:column>
                                  <rich:column>
                                       <f:facet name="header">Sp.Ed</f:facet>
                                       #{family.specialedfamily} </rich:column>
                                  <rich:column>
                                       <f:facet name="header">Parents</f:facet>
                                       <ui:repeat value="#{family.parentList}" var="parent" rendered="#{0 ne family.parentList.size()}">
                                            <div>#{parent.firstname} #{parent.lastname}</div>
                                       </ui:repeat>
                                  </rich:column>
                                  <rich:column>
                                       <f:facet name="header">Children</f:facet>
                                       <ui:repeat value="#{family.learnerList}" var="learner" rendered="#{0 ne family.learnerList.size()}" >
                                            <div class="#{learner.styleClass}"> #{learner.firstname} #{learner.lastname} </div>
                                       </ui:repeat>
                                  </rich:column>
                                  <rich:column>
                                       <f:facet name="header">FTE</f:facet>
                                       <h:dataTable value="#{family.learnerList}" var="learner" rendered="#{0 ne family.learnerList.size()}" >
                                            <h:column>#{learner.fteNextYearValue()}</h:column>
                                       </h:dataTable>
                                  </rich:column>
                                  <rich:column>
                                       <f:facet name="header"># Parents</f:facet>
                                       <s:div rendered="#{0 ne family.parentList.size()}">#{family.parentList.size()}</s:div>
                                  </rich:column>
                                  <rich:column>
                                       <f:facet name="header"># Kids</f:facet>
                                       <s:div rendered="#{0 ne family.learnerList.size()}">#{family.learnerList.size()}</s:div>
                                  </rich:column>
                                  <rich:column style="color:green;">
                                       <f:facet name="header">Years</f:facet>
                                       <ui:repeat value="#{family.learnerList}" var="learner" rendered="#{0 ne family.learnerList.size()}">
                                            <s:div rendered="#{0 ne learner.learnerEnrollmentList.size()}">
                                                 <ui:repeat value="#{learner.learnerEnrollmentList}" var="learnerEnrollment">
                                                  <s:fragment rendered="#{learnerEnrollment.enrollmentyear.name eq extranetSession.enrollmentyear.name}">
                                                  
                                                      <s:fragment rendered="#{authenticator.planners}">
                                                           <s:div rendered="#{not empty learnerEnrollment.enrollmentStatus and learnerEnrollment.enrollmentStatus.statusName eq 'Withdrawn'}" style="color:red;">
                                                                <s:link  style="color:red" value="#{learnerEnrollment.enrollmentyear.organization.name}: #{learnerEnrollment.program.name} :#{learnerEnrollment.enrollmentyear.name} - Grade: #{learnerEnrollment.grade.gradeCode}" view="/executive/planners/learnerOverview.xhtml">
                                                                     <f:param name="learnerEnrollmentLearnerenrollmentid" value="#{learnerEnrollment.learnerenrollmentid}"/>
                                                                     <f:param name="fromPage" value="familySearch"/>
                                                                </s:link>
                                                           </s:div>
                                                           <s:div rendered="#{not empty learnerEnrollment.enrollmentStatus and learnerEnrollment.enrollmentStatus.statusName eq 'Enrolled'}">
                                                                <s:link  style="color:green" value="#{learnerEnrollment.enrollmentyear.organization.name}: #{learnerEnrollment.program.name} :#{learnerEnrollment.enrollmentyear.name} - Grade: #{learnerEnrollment.grade.gradeCode}" view="/executive/planners/learnerOverview.xhtml">
                                                                     <f:param name="learnerEnrollmentLearnerenrollmentid" value="#{learnerEnrollment.learnerenrollmentid}"/>
                                                                     <f:param name="fromPage" value="familySearch"/>
                                                                </s:link>
                                                           </s:div>
                                                      </s:fragment>
                                                      <s:fragment rendered="#{not authenticator.planners}">
                                                           <s:div rendered="#{not empty learnerEnrollment.withdrawn}" style="color:red;"> #{learnerEnrollment.enrollmentyear.organization.name}: #{learnerEnrollment.program.name} :#{learnerEnrollment.enrollmentyear.name} - Grade: #{learnerEnrollment.grade.gradeCode} </s:div>
                                                           <s:div rendered="#{empty learnerEnrollment.withdrawn}"> #{learnerEnrollment.enrollmentyear.organization.name}: #{learnerEnrollment.program.name} :#{learnerEnrollment.enrollmentyear.name} - Grade: #{learnerEnrollment.grade.gradeCode}</s:div>
                                                      </s:fragment>
                                                      </s:fragment>
                                                 </ui:repeat>
                                                 
                                            </s:div>
                                       </ui:repeat>
                                       <s:div rendered="#{0 eq family.parentList.size()}" 
                                                                style="width:50px; background:orange; color:black; padding:2px">No Parent</s:div>
                                       <s:div rendered="#{0 eq family.learnerList.size()}" 
                                                                style="width:50px; background:red; color:white; padding:2px">No Child</s:div>
                                  </rich:column>
                                  <rich:column>
                                       <f:facet name="header">LC Selected</f:facet>
                                       <ui:repeat value="#{family.learnerList}" var="learner" rendered="#{0 ne family.learnerList.size()}">
                                            <s:div rendered="#{0 ne learner.learnerEnrollmentList.size()}">
                                                 <ui:repeat value="#{learner.learnerEnrollmentList}" var="learnerEnrollment">
                                                      <ui:repeat value="#{learnerEnrollment.learnerConsultantMatchList}" var="learnerConsultantMatch">
                                                           <s:div rendered="#{learnerConsultantMatch.active eq true}"> #{learnerConsultantMatch.consultantEnrollment.consultant.firstname} #{learnerConsultantMatch.consultantEnrollment.consultant.lastname} </s:div>
                                                      </ui:repeat>
                                                 </ui:repeat>
                                            </s:div>
                                       </ui:repeat>
                                  </rich:column>
                                  <rich:column>
                                       <f:facet name="header">FC Welcome Email</f:facet>
                                       <s:div rendered="#{family.firstClassAccounts}">
                                            <h:outputText value="#{family.firstClassAccountsCreated}" >
                                                 <f:convertDateTime type="date" dateStyle="medium"/>
                                            </h:outputText>
                                       </s:div>
                                  </rich:column>
                             </rich:dataTable>
              



              FamilySearchList.java



              ...
              
              @Name("familySearchList")
              @Scope(ScopeType.EVENT)
              public class FamilySearchList extends EntityQuery<Family>
              {
              
              
              
                   /**
                    * 
                    */
                   private static final long serialVersionUID = 6136996917135607642L;
              
                   private Organization organization = new Organization();
                   private Program program = new Program();
                   private Parent parent = new Parent();   
                   private Learner learner = new Learner();
                   private SpecialEdLearner specialed = new SpecialEdLearner();
                   private EnrollmentYear enrollmentYear = new EnrollmentYear();
                   private Family family = new Family();
                   private LearnerEnrollment learnerEnrollment = new LearnerEnrollment();
              
                   
                   public LearnerEnrollment getLearnerEnrollment() {
                        return learnerEnrollment;
                   }
              
                   public Family getFamily() {
                        return family;
                   }
              
                   public void setFamily(Family family) {
                        this.family = family;
                   }
              
                   public SpecialEdLearner getSpecialed() {
                        return specialed;
                   }
              
                   public void setSpecialed(SpecialEdLearner specialed) {
                        this.specialed = specialed;
                   }
              
                   @Override
                  public String getEjbql() 
                  { 
                        
                        
                      return getSQL();
              
                    
                  }
                   
                   @Override
                   public Long getResultCount(){
                        StringBuffer buf = new StringBuffer("select count(distinct family) from Family family join family.learnerList as learner1 join learner1.learnerEnrollmentList as enrollmentlist1 join enrollmentlist1.program as program1 join program1.organization organization1 join enrollmentlist1.enrollmentyear enrollmentyear1 where family.familyid in (select family2.familyid from Family family2  join family2.parentList as parent  join family2.learnerList as learner join learner.learnerEnrollmentList as enrollmentlist join enrollmentlist.program as program join program.organization organization join enrollmentlist.enrollmentyear enrollmentyear join learner.specialedlearner as specialedlearner where ");
                        
                        
                        buf.append("program.id = ");
                        buf.append(this.getProgram().getId());
                        buf.append(" and ");
                        buf.append("organization.organizationid = ");
                        buf.append(this.getOrganization().getOrganizationid());
                        buf.append(" and ");
                        buf.append("enrollmentyear.enrollmentyearid = ");
                        buf.append(this.getEnrollmentYear().getEnrollmentyearid());
              
              
              ..... blah blah blah other sql stuff (sub select and such)
              
                        Query countQuery = getEntityManager().createQuery(buf.toString());
                        
                        Long result = (Long)countQuery.getSingleResult();
                        
                        return result;
                   }
                   
                   private String getSQL()
                   {
                        StringBuffer buf = new StringBuffer("select distinct family from Family family join family.learnerList as learner1 join learner1.learnerEnrollmentList as enrollmentlist1 join enrollmentlist1.program as program1 join program1.organization organization1 join enrollmentlist1.enrollmentyear enrollmentyear1 where family.familyid in (select family2.familyid from Family family2 join family2.parentList as parent join family2.learnerList as learner join learner.learnerEnrollmentList as enrollmentlist join enrollmentlist.program as program join program.organization organization join enrollmentlist.enrollmentyear enrollmentyear join learner.specialedlearner as specialedlearner where ");
                        
                        
                        buf.append("program.id = ");
                        buf.append(this.getProgram().getId());
                        buf.append(" and ");
                        buf.append("organization.organizationid = ");
                        buf.append(this.getOrganization().getOrganizationid());
                        buf.append(" and ");
                        buf.append("enrollmentyear.enrollmentyearid = ");
                        buf.append(this.getEnrollmentYear().getEnrollmentyearid());
              
              
              ..... blah blah blah other sql stuff (sub select and such)
              
              
                        
                        return buf.toString();
                   }
                   
                  
                   @Override
                   public Long getLastFirstResult(){
              
                        
                        return super.getLastFirstResult();
                   }
                   
              
                   
              
              
                   public Parent getParent() {
                        return parent;
                   }
              
                   public void setParent(Parent parent) {
                        this.parent = parent;
                   }
              
                   public Learner getLearner() {
                        return learner;
                   }
              
                   public void setLearner(Learner learner) {
                        this.learner = learner;
                   }
              
                   public Organization getOrganization() {
                        return organization;
                   }
              
                   public void setOrganization(Organization organization) {
                        this.organization = organization;
                   }
              
                   public Program getProgram() {
                        return program;
                   }
              
                   public void setProgram(Program program) {
                        this.program = program;
                   }
              
                   public EnrollmentYear getEnrollmentYear() {
                        return enrollmentYear;
                   }
              
                   public void setEnrollmentYear(EnrollmentYear enrollmentyear) {
                        this.enrollmentYear = enrollmentyear;
                   }
                   
                   
                   public Long reEnrollmentFamilies(){
                        Query q = getEntityManager().createNamedQuery("findReEnrollments");
                        
                        Long reEnrollCount = (Long)q.getSingleResult();
                        return reEnrollCount;
                   }
                   
                   public Long newEnrollmentFamilies(){
                        Query q = getEntityManager().createNamedQuery("findNewEnrollments");
                        
                        Long reEnrollCount = (Long)q.getSingleResult();
                        return reEnrollCount;
                   }
              
              }
              
              


              • 4. Re: trying to understand s:link and queries firing on following pages
                Pucky Loucks Newbie

                I figured it out.  I missed the step that by using a page.xml it will PRELOAD the data.  now that totally makes sense as to why as more and more data is added the system gets slowing and slower. 


                Back to @RequestParamters I go. ;)


                whew glad I found that.


                Thanks all.