简体   繁体   中英

Java/J2EE Internal Server Error

I have a DaoHibernateImpl file which is breaking my application. Here is the code for this and its xml.

    public class OfferBankDaoHibernateImpl extends GenericDaoHibernateImpl<OfferBank, Long> implements OfferBankDao {

        static Logger log = Logger.getLogger(OfferBankDaoHibernateImpl.class);
        private ResourceManager rMgr = new ResourceManager(this);

        public List<OfferBank> findOfferBankByName(String offerBankNm) throws AppException {
            List<OfferBank> offerBanks = new ArrayList<OfferBank>();
            try {
                // offerBanks =
                // sessionFactory.getCurrentSession().createCriteria(OfferBank.class)
                // .add( Restrictions.eq("offerBankNm", offerBankNm))
                // .list();

                offerBanks = sessionFactory.getCurrentSession().createQuery("from OfferBank ob where ob.offerBankNm = '" + offerBankNm + "'").list();
            } catch (GenericJDBCException e) {
                log.error(e.getMessage(), e);
                throw new AppException(e.getMessage(), e);
            } catch (HibernateException e) {
                log.error(e.getMessage(), e);
                throw new AppException(e.getMessage(), e);
            }
            return offerBanks;
        }

        public Object[] getOfferBanks(List<String> offerBankTypes, int startPos, int endPos, List<Long> statusIds) {
            int totalRowCount = 1000000;
            try {
                if (endPos == 0) {
                    endPos = totalRowCount;
                }
                String dataSql = rMgr.get("sql.offer_bank_get_banks");
                dataSql += " " + rMgr.get("sql.offer_bank_get_banks_types_where");
                if (!statusIds.isEmpty()) {
                    dataSql += " " + rMgr.get("sql.offer_bank_get_banks_status_where");
                }
                dataSql += " " + rMgr.get("sql.offer_banks_get_banks_group_by");

                log.debug("query : " + dataSql);
                SQLQuery dataQuery = this.sessionFactory.getCurrentSession().createSQLQuery(dataSql);
                if (!statusIds.isEmpty()) {
                    dataQuery.setParameterList("offerBankStatusIds", statusIds);
                }
                dataQuery.setParameterList("offerBankTypes", offerBankTypes).setParameter("start", startPos).setParameter("end", endPos);
                List offerBankList = dataQuery.list();
                return makeOfferBankTO(offerBankList);
            } catch (RuntimeException e) {
                log.error("Error getOfferBanks(List<Long> offerBankTypes ,int startPos, int endPos, List<Long> statusIds)");
                throw e;
            }
        }



        public Object[] getOfferBanksByBanner(List<String> offerBankTypes, int startPos, int endPos, List<Long> statusIds) {
            int totalRowCount = 1000000;
            try {
                if (endPos == 0) {
                    endPos = totalRowCount;
                }
                String dataSql = rMgr.get("sql.offer_bank_get_banks_by_banner");
                dataSql += " " + rMgr.get("sql.offer_bank_get_banks_types_where");
                if (!statusIds.isEmpty()) {
                    dataSql += " " + rMgr.get("sql.offer_bank_get_banks_status_where");
                }
                dataSql += " " + rMgr.get("sql.offer_banks_get_banks_by_banner_group_by");

                log.debug("query : " + dataSql);
                SQLQuery dataQuery = this.sessionFactory.getCurrentSession().createSQLQuery(dataSql);
                if (!statusIds.isEmpty()) {
                    dataQuery.setParameterList("offerBankStatusIds", statusIds);
                }
                dataQuery.setParameterList("offerBankTypes", offerBankTypes).setParameter("start", startPos).setParameter("end", endPos);
                List offerBankList = dataQuery.list();
                return makeOfferBankTO(offerBankList);
            } catch (RuntimeException e) {
                log.error("Error getOfferBanksByBanner(List<Long> offerBankTypes ,int startPos, int endPos, List<Long> statusIds)");
                throw e;
            }
        }

        public Object[] getOfferBankById(List<Long> offerBankIds) {
            int startPos = 1;
            int endPos = 100000;
            String dataSql = rMgr.get("sql.offer_bank_get_banks");
            dataSql += " " + rMgr.get("sql.offer_bank_get_banks_ids_where");
            dataSql += " " + rMgr.get("sql.offer_banks_get_banks_group_by");
            log.debug("sql= " + dataSql);
            SQLQuery dataQuery = this.sessionFactory.getCurrentSession().createSQLQuery(dataSql);
            dataQuery.setParameterList("offerBankIds", offerBankIds).setParameter("start", startPos).setParameter("end", endPos);
            List offerBankList = dataQuery.list();
            return makeOfferBankTO(offerBankList);
        }

        private Object[] makeOfferBankTO(List offerBankList) {
            int totalRowCount = 0;
            List<OfferBankTO> offerBankTOs = new ArrayList<OfferBankTO>();
            Iterator iter = offerBankList.iterator();
            while (iter.hasNext()) {
                Object[] row = (Object[]) iter.next();
                OfferBankTO ob = new OfferBankTO();
                ob.setOfferBankId(((BigDecimal) row[0]).longValue());
                ob.setPromotionalPeriodId(((BigDecimal) row[1]).longValue());
                ob.setOfferBankName(row[2].toString());
                ob.setOfferBankStatusDesc(row[3].toString());
                if (row[4] != null) {
                    ob.setStartDate(DateFormats.dateFmt.format((Date) row[4]));
                }
                if (row[5] != null) {
                    ob.setEndDate(DateFormats.dateFmt.format((Date) row[5]));
                }
                ob.setOfferBankTypeDesc(row[6].toString());
                ob.setOfferBankTypeCd(row[7].toString());
                ob.setPromotionalPeriodNm(row[8].toString());
                ob.setTotalCount(((Integer) row[9]).intValue());
                ob.setEditingCount(((Integer) row[10]).intValue());
                ob.setFailedDeactiveCount(((Integer) row[11]).intValue());
                ob.setFailedProductionCount(((Integer) row[12]).intValue());
                ob.setFailedPreviewCount(((Integer) row[13]).intValue());
                ob.setLoadedCount(((Integer) row[14]).intValue());
                ob.setPendingCount(((Integer) row[15]).intValue());
                ob.setParkedCount(((Integer) row[16]).intValue());
                ob.setSuccessDeactivatedCount(((Integer) row[17]).intValue());
                ob.setSuccessLoadedProdCount(((Integer) row[18]).intValue());
                ob.setSuccessLoadedPreviewCount(((Integer) row[19]).intValue());
                ob.setTotalPendingCount(((Integer) row[20]).intValue());
                ob.setTotalFailedCount(((Integer) row[21]).intValue());
                totalRowCount = ((Integer) row[22]).intValue();
                if (row[24] != null)
                    ob.setMaxOfferEffectiveEndDt(DateFormats.dateFmt.format((Date) row[24]));
                if (row[25] != null)
                    ob.setMinOfferEffectiveStartDt(DateFormats.dateFmt.format((Date) row[25]));

                ob.setEndedCount(((Integer) row[26]).intValue());
                ob.setCopientDelayCount(((Integer) row[27]).intValue());
                ob.setRejectedCount(((Integer) row[28]).intValue());
                ob.setProcessingCount(((Integer) row[29]).intValue());

                if (row.length > 30) {
                    if (row[30] != null) {
                        ob.setRegionId(row[30].toString());
                    }
                    if (row[31] != null) {
                        ob.setRegionNm(row[31].toString());
                    }
                }

                offerBankTOs.add(ob);
            }
            return new Object[] { totalRowCount, offerBankTOs };
        }

        public Object[] getBankTypes() {
            List<OfferBankTypeTO> offerBankTypes = new ArrayList<OfferBankTypeTO>();
            try {
                String sql = rMgr.get("sql.offer_bank_types");
                SQLQuery query = this.sessionFactory.getCurrentSession().createSQLQuery(sql);

                List typeList = query.list();

                Iterator iter = typeList.iterator();
                while (iter.hasNext()) {
                    Object[] row = (Object[]) iter.next();
                    OfferBankTypeTO type = new OfferBankTypeTO();
                    type.setOfferBankTypeCd(row[0].toString());
                    type.setOfferBankTypeDesc(row[1].toString());
                    offerBankTypes.add(type);
                }

            } catch (RuntimeException e) {
                log.error("Error List<OfferBankType> getBankTypes()");
                throw e;
            }
            return new Object[] { offerBankTypes };
        }

        public void updateOfferBank(OfferBank offerBank, Context ctx) {

            String user = (ctx != null && ((UserContext) ctx).getUserName() != null && ((UserContext) ctx).getUserName().length() > 0) ? ((UserContext) ctx)
                    .getUserName() : SharedMessages.getString("user.default");

            offerBank.setLastUpdtTs(new Date(System.currentTimeMillis()));
            offerBank.setLastUpdtUserId(user);

            this.makePersistent(offerBank);
        }

        public OfferBank addOfferBank(OfferBank offerBank, Context ctx) {
            String user = (ctx != null && ((UserContext) ctx).getUserName() != null && ((UserContext) ctx).getUserName().length() > 0) ? ((UserContext) ctx)
                    .getUserName() : SharedMessages.getString("user.default");
            Date now = new Date(System.currentTimeMillis());
            offerBank.setLastUpdtTs(now);
            offerBank.setLastUpdtUserId(user);
            offerBank.setCreationUserId(user);
            offerBank.setCreationTs(now);

            return this.insert(offerBank);
        }

        public int updateCurrentBankStatus(OfferBank offerBank, Context ctx) {
            String sql = rMgr.get("sql.update_current_bank_status");
            SQLQuery query = this.sessionFactory.getCurrentSession().createSQLQuery(sql);
            query.setParameter("offer_bank_id", offerBank.getOfferBankId());
            return query.executeUpdate();
        }

        public void insertBankStatus(OfferBank offerBank, short newStatusId, Context ctx) {
            String user = (ctx != null && ((UserContext) ctx).getUserName() != null && ((UserContext) ctx).getUserName().length() > 0) ? ((UserContext) ctx)
                    .getUserName() : SharedMessages.getString("user.default");
            OfferBankStatus offerBankStatus = new OfferBankStatus();
            OfferBankStatusId offerBankStatusId = new OfferBankStatusId();
            Date now = new Date(System.currentTimeMillis());
            DateFormat df = new SimpleDateFormat("yyyy-MM-dd");

            offerBankStatusId.setOfferBankId(offerBank.getOfferBankId());
            offerBankStatusId.setEffectiveStartDt(now);
            offerBankStatus.setId(offerBankStatusId);
            offerBankStatus.setCreationTs(now);
            offerBankStatus.setCreationUserId(user);
            offerBankStatus.setEffectiveEndDt(null);
            offerBankStatus.setLastUpdtTs(now);
            offerBankStatus.setLastUpdtUserId(user);

            this.sessionFactory.getCurrentSession().save(offerBankStatus);
        }

        /*public void addOfferBankRegions(List<OfferBankCluster> obRegionList, Context ctx) {
            String user = (ctx != null && ((UserContext) ctx).getUserName() != null && ((UserContext) ctx).getUserName().length() > 0) ? ((UserContext) ctx)
                    .getUserName() : SharedMessages.getString("user.default");
            Date now = new Date(System.currentTimeMillis());

            for (OfferBankCluster obc : obRegionList) {
                obc.setCreationUserId(user);
                obc.setCreationTs(now);
                obc.setLastUpdtTs(now);
                obc.setLastUpdtUserId(user);

                this.sessionFactory.getCurrentSession().save(obc);
            }
        }*/
    }

and the xml file is:

    <?xml version="1.0" encoding="UTF-8"?>
<properties>    
    <sql>

        <offer_bank_get_banks>
            select * from (
                select 
                    ob.offer_bank_id
                    , ob.promotional_period_id
                    , ob.offer_bank_nm
                    , obst.offer_bank_status_type_dsc
                    , ob.effective_start_dt
                    , ob.effective_end_dt
                    , obt.offer_bank_type_dsc
                    , obt.offer_bank_type_cd
                    , pp.promotional_period_nm
                    , SUM(CASE WHEN a.offer_id IS NOT NULL THEN 1 ELSE 0 END) as total_count
                    , SUM(CASE WHEN a.offer_status_type_cd = 'ED' THEN 1 ELSE 0 END) as editing_count
                    , SUM(CASE WHEN a.offer_status_type_cd = 'FD' THEN 1 ELSE 0 END) as failed_deactive_count
                    , SUM(CASE WHEN a.offer_status_type_cd in ('FP', 'FI') THEN 1 ELSE 0 END) as failed_production_count
                    , SUM(CASE WHEN a.offer_status_type_cd = 'FV' THEN 1 ELSE 0 END) as failed_preview_count
                    , SUM(CASE WHEN a.offer_status_type_cd = 'LD' THEN 1 ELSE 0 END) as loaded_count                 
                    , SUM(CASE WHEN a.offer_status_type_cd in ('PE', 'PS') THEN 1 ELSE 0 END) as pending_count
                    , SUM(CASE WHEN a.offer_status_type_cd = 'PK' THEN 1 ELSE 0 END) as parked_count
                    , SUM(CASE WHEN a.offer_status_type_cd = 'SD' THEN 1 ELSE 0 END) as successfully_deactivated_count
                    , SUM(CASE WHEN a.offer_status_type_cd in ('SP','PI') THEN 1 ELSE 0 END) as successfully_loaded_to_prod_count
                    , SUM(CASE WHEN a.offer_status_type_cd = 'SV' THEN 1 ELSE 0 END) as successfully_loaded_to_preview_count                
                    , SUM(CASE WHEN a.offer_status_type_cd in ('LD','PE','PS') THEN 1 ELSE 0 END) as total_pending_count        
                    , SUM(CASE WHEN a.offer_status_type_cd in ('FD','FP','FV','FR','FI') THEN 1 ELSE 0 END) as failed_count
                    , COUNT(1) OVER(PARTITION BY 1) as total_rows
                    , ROW_NUMBER() OVER (ORDER BY ob.effective_end_dt desc) as row_nbr   
                    , MAX(a.offer_effective_end_dt)as max_offer_effective_end_dt
                    , MIN(a.offer_effective_start_dt)as min_offer_effective_start_dt
                    , SUM(CASE WHEN a.offer_status_type_cd in('AR','SR','SD') THEN 1 ELSE 0 END) as ended_count  
                    , SUM(CASE WHEN a.offer_status_type_cd in('CD') THEN 1 ELSE 0 END) as copient_delay_count
                    , SUM(CASE WHEN a.offer_status_type_cd in('SR') THEN 1 ELSE 0 END) as rejected_count
                    , SUM(CASE WHEN a.offer_status_type_cd in('LV', 'GV', 'CD', 'GA', 'GC', 'GD', 'GI', 'GP', 'GR', 'LA', 'LI', 'LP', 'LR', 'LV', 'LE')
                        THEN 1 ELSE 0 END) as processing_count
                from 
                    ${sql.database}.offer_bank ob
                    INNER JOIN ${sql.database}.offer_bank_status obs
                    ON ob.offer_bank_id = obs.offer_bank_id
                    INNER JOIN ${sql.database}.offer_bank_status_type obst
                    ON obs.offer_bank_status_type_cd = obst.offer_bank_status_type_cd
                    INNER JOIN ${sql.database}.promotional_period pp
                    ON ob.promotional_period_id = pp.promotional_period_id
                    INNER JOIN ${sql.database}.offer_bank_type obt
                    ON ob.offer_bank_type_cd = obt.offer_bank_type_cd               
                    LEFT OUTER JOIN 
                        (Select 
                            o.offer_id
                            , o.offer_bank_id
                            , ost.offer_status_type_cd
                            , o.offer_effective_end_dt
                            , o.offer_effective_start_dt
                         from 
                            ${sql.database}.offer o                        
                            INNER JOIN ${sql.database}.offer_status os
                            ON o.offer_id = os.offer_id
                            INNER JOIN ${sql.database}.offer_status_type ost
                            ON os.offer_status_type_cd = ost.offer_status_type_cd
                            AND os.effective_end_dt is null
                        ) a
                    ON ob.offer_bank_id = a.offer_bank_id
                where
                    obs.effective_end_dt is null     
         </offer_bank_get_banks>

and error stack being:

20:52:16,069 ERROR JDBCExceptionReporter:101 - ORA-00972: identifier is too long

20:52:16,070 ERROR OfferBankDaoHibernateImpl:77 - Error getOfferBanks(List<Long> offerBankTypes ,int startPos, int endPos, List<Long> statusIds)
Jul 19, 2013 8:52:16 PM org.restlet.resource.UniformResource doCatch
WARNING: Exception or error caught in resource

My code is breaking at OfferBankDaoHibernateImpl. To me it seems the method getOfferBanks(List offerBankTypes ,int startPos, int endPos, List statusIds) is breaking. If anyone has come across a similar situation, it will help?

ORA-00972: identifier is too long tells you what the issue is. The max length of an identifier is 30 characters in Oracle, and you have a couple aliases that are longer than 30 characters. For example, successfully_loaded_to_prod_count is 33 characters.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM