-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: need help aggregating/eliminating repeating data
PostPosted: Mon Apr 07, 2008 8:17 pm 
Code:
ICOMS User  Supervisor    Disapproval Type(s)

ORGARSOO    Brenden Tkach Wrong supervisor for user
ORGARSOO    Brenden Tkach User should not have ICOMS login
ORGARSOO    Brenden Tkach Wrong ICOMS security group
ORGARSOO    Brenden Tkach Wrong adjustment limit


with the above list being outjected by a Seam SFSB to a dataTable UI component in a JSF (this is a Seam app with Oracle 10g), what is the best way to eliminate the redundant data in the columns?

In other words, how can I write the native sql query via session.createSQLQuery() or HQL such that it displays like:

Code:
ORGARSOO Brenden Tkach [drop-down for third non-repeating column]


it's easier to read when there's only one row for that resultset. Or is there a better way to handle this? I tried group by and distinct but not sure if they apply in this scenario. thx.


Top
  
 
 Post subject:
PostPosted: Mon Apr 07, 2008 8:20 pm 
this is the generated SQL from Hibernate:

Code:
SELECT
        tbb.BILLINGKEY as BILLINGKEY9_0_,
        tbb.SITEKEY as SITEKEY9_0_,
        tbb.SALESNUMBER as SALESNUM3_9_0_,
        tbb.LOGIN as LOGIN9_0_,
        tbb.EMPLOYEETYPECODE as EMPLOYEE5_9_0_,
        tbb.EMPLOYEENUMBER as EMPLOYEE6_9_0_,
        tbb.PURGED_IND as PURGED7_9_0_,
        tbb.PROCESS_FLG as PROCESS8_9_0_,
        tbb.CREATEDT as CREATEDT9_0_,
        tbb.LASTUPDATEDT as LASTUPD10_9_0_,
        tmus.USERSUPERVISORKEY as USERSUPE1_14_1_,
        tmus.USERKEY as USERKEY14_1_,
        tmus.SUPERVISORKEY as SUPERVIS3_14_1_,
        tmus.CREATEDT as CREATEDT14_1_,
        tmus.EFFECTIVESTARTDATE as EFFECTIV5_14_1_,
        tmus.EFFECTIVEENDDATE as EFFECTIV6_14_1_,
        tmus.CURRENTFLG as CURRENTFLG14_1_,
        dt.DISAPPROVAL_TYPE_ID as DISAPPRO1_3_2_,
        dt.DESCRIPTION as DESCRIPT2_3_2_,
        s.SITE_ID as SITE1_8_3_,
        s.NAME as NAME8_3_,
        s.CODE as CODE8_3_,
        ia.AUDIT_ID as AUDIT1_5_4_,
        ia.START_DATE as START2_5_4_,
        ia.DESCRIPTION as DESCRIPT3_5_4_,
        ia.SITE_ID as SITE5_5_4_,
        ia.END_DATE as END4_5_4_,
        ast.AUDIT_STATUS_ID as AUDIT1_2_5_,
        ast.DESCRIPTION as DESCRIPT2_2_5_
    FROM
        Employee e,
        Tbuser tbu,
        Tmuserbilling tmub,
        Tbbilling tbb,
        Audit_Status ast,
        Tmusersupervisor tmus,
        Note n,
        Activity a,
        Icoms_Audit ia,
        Disapproval_Type dt,
        Site s
    WHERE
        e.idm_user_id = tbu.userkey
        AND e.audit_status_id = ast.audit_status_id
        AND e.audit_id = ia.audit_id
        AND tbu.userkey = tmub.userkey
        AND tmub.billingkey = tbb.billingkey
        AND tbu.userkey = tmus.userkey
        AND e.employee_id = a.employee_id
        AND a.activity_id = n.activity_id
        AND dt.disapproval_type_id = n.disapproval_type_id
        AND s.site_id = ia.site_id
        AND ast.audit_status_id in (
            3, 4
        )


based on this method:

Code:
   public List searchAuditedUsers(String selectedSite, String selectedAudit, String icomsUser, String disapprovalType, String supervisorLastName, Boolean init){
      
      log.info("begin searchAuditedUsers");
      
      log.info("searchAuditedUsers(): selectedSite = " + selectedSite);
      log.info("searchAuditedUsers(): selectedAudit = " + selectedAudit);
      log.info("searchAuditedUsers(): icomsUser = " + icomsUser);
      log.info("searchAuditedUsers(): disapprovalType = " + disapprovalType);
      log.info("searchAuditedUsers(): supervisorLastName = " + supervisorLastName);
      log.info("searchAuditedUsers(): init = " + init);
      
      List list;
      int ctr = 0;
         
      StringBuffer query = new StringBuffer("SELECT {tbb.*}," +
            "                             {tmus.*}," +
            "                             {dt.*}, " +
            "                             {s.*}, " +
            "                             {ia.*}, " +
            "                             {ast.*} "+
                                    "FROM Employee e, "+
                                       "Tbuser tbu, "+
                                       "Tmuserbilling tmub, "+
                                       "Tbbilling tbb, "+
                                       "Audit_Status ast, "+
                                       "Tmusersupervisor tmus, "+
                                       "Note n, "+
                                       "Activity a, "+
                                       "Icoms_Audit ia, "+
                                       "Disapproval_Type dt, "+
                                       "Site s "+                                       
                                       "WHERE    e.idm_user_id = tbu.userkey "+
                                       "AND e.audit_status_id = ast.audit_status_id "+
                                       "AND e.audit_id = ia.audit_id "+
                                       "AND tbu.userkey = tmub.userkey "+
                                       "AND tmub.billingkey = tbb.billingkey "+
                                       "AND tbu.userkey = tmus.userkey "+
                                       "AND e.employee_id = a.employee_id "+
                                       "AND a.activity_id = n.activity_id "+
                                       "AND dt.disapproval_type_id = n.disapproval_type_id "+
                                       "AND s.site_id = ia.site_id");
      
      
            
      //add appenders
      if (init != null && init == true) {
         query.append(" AND ast.audit_status_id in (3, 4)");  //if report is access the first time in session, result set should be filtered for disapproved and disapproved in process
      }
      if (selectedSite != null && selectedSite.trim().length() > 0) {
         query.append(" AND ia.site_id = ? ");
      }
      if (selectedAudit != null && selectedAudit.trim().length() > 0) {
         query.append(" AND ia.audit_id = ?");
      }      
      if (icomsUser != null && icomsUser.trim().length() > 0)   {
         query.append(" AND LOWER(tbb.login) like LOWER(?) ");
      }
      if (disapprovalType != null && disapprovalType.trim().length() > 0) {
         query.append(" AND n.disapproval_type_id = ?");
      }
      if (supervisorLastName != null && supervisorLastName.trim().length() > 0) {         
         query.append(" AND tmus.supervisorkey in (SELECT tbu.userkey FROM Tbuser tbu WHERE LOWER(tbu.lastname) like LOWER(?))");
      }
      
      Session session = (Session) entityManager.getDelegate();
         
      SQLQuery q = session.createSQLQuery(query.toString())
                     .addEntity("tbb", Tbbilling.class)
                     .addEntity("tmus", Tmusersupervisor.class)
                     .addEntity("dt", DisapprovalType.class)
                     .addEntity("s", Site.class)
                     .addEntity("ia", IcomsAudit.class)
                     .addEntity("ast", AuditStatus.class);
      
      //set params   
      if (selectedSite != null && selectedSite.trim().length() > 0) {
         q.setParameter(ctr++, Integer.parseInt(selectedSite.trim()));
      }
      if (selectedAudit != null && selectedAudit.trim().length() > 0) {
         q.setParameter(ctr++, Integer.parseInt(selectedAudit.trim()));
      }   
      if (icomsUser != null && icomsUser.trim().length() > 0) {
         q.setParameter(ctr++, "%"+icomsUser.trim()+"%");
      }
      if (disapprovalType != null && disapprovalType.trim().length() > 0) {
         q.setParameter(ctr++, Integer.parseInt(disapprovalType.trim()));
      }
      if (supervisorLastName != null && supervisorLastName.trim().length() > 0) {
         q.setParameter(ctr++, "%"+supervisorLastName.trim()+"%");
      }
      
      list = q.list();
   
      return list;
   }


Top
  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.