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.  [ 3 posts ] 
Author Message
 Post subject: Infinite loop on simple get()
PostPosted: Mon Jun 29, 2009 6:09 pm 
Newbie

Joined: Mon Jun 29, 2009 5:29 pm
Posts: 3
Hello. This is my first post on this forum, so I hope I've included all of the information necessary to identify the problem.

I am converting a legacy application to use Hibernate for data persistence and have run into a strange and rather troubling bug. When retrieving an object from one of the tables in the database, Hibernate enters into an infinite loop, repeatedly sending the same query. Here is the method that appears to trigger this state:

Code:
   public ClaimT findById(Long id) {
      log.debug("getting ClaimT instance with id: " + id);
        try {
           ClaimT instance = (ClaimT) session
                    .get(ClaimT.class, id);
            if (instance==null) {
                log.debug("get successful, no instance found");
            }
            else {
                log.debug("get successful, instance found");
            }
            return instance;
        }
        catch (RuntimeException re) {
            log.error("get failed", re);
            throw re;
        }
   }

The infinite loop begins when the session.get(ClaimT.class, id) method is called. At that point, the following query is printed repeatedly to my console (I apologize for the length of the query; the database is old and poorly normalized):
Quote:
[6/29/09 16:41:56:616 CDT] 00000020 SystemOut O Hibernate: select claimt0_.CL_ID as CL1_28_0_, claimt0_.CL_OIT_CODE_FK as CL2_28_0_, claimt0_.CL_OLI_CODE_FK as CL3_28_0_, claimt0_.CL_IUI_CODE_FK as CL4_28_0_, claimt0_.CL_CEM_CODE_FK as CL5_28_0_, claimt0_.CL_CCA_CODE_FK as CL6_28_0_, claimt0_.CL_PAYEE_IND_FK as CL7_28_0_, claimt0_.CL_SI_CODE_FK as CL8_28_0_, claimt0_.CL_ST_CODE_FK as CL9_28_0_, claimt0_.CL_DR_CODE_FK as CL10_28_0_, claimt0_.CL_CR_CODE_FK as CL11_28_0_, claimt0_.CL_DIS_ARTICLE_STA_CODE_FK as CL12_28_0_, claimt0_.CL_PIC_NBR as CL13_28_0_, claimt0_.CL_COD_NBR as CL14_28_0_, claimt0_.CL_PACKAGE_WEIGHT_LBS as CL15_28_0_, claimt0_.CL_FA_CERTIFICATION_NO as CL16_28_0_, claimt0_.CL_DISPATCHING_XO as CL17_28_0_, claimt0_.CL_RECEIVING_XO as CL18_28_0_, claimt0_.CL_RESPONSIBILITY_IND as CL19_28_0_, claimt0_.CL_PROOF_SIGNATURE_IND as CL20_28_0_, claimt0_.CL_PROOF_DELIVERY_IND as CL21_28_0_, claimt0_.CL_PROOF_INSURANCE_IND as CL22_28_0_, claimt0_.CL_PROOF_VALUE_IND as CL23_28_0_, claimt0_.CL_PROOF_DAMAGE_IND as CL24_28_0_, claimt0_.CL_PROOF_LOSS_IND as CL25_28_0_, claimt0_.CL_ORIGINATOR_IND as CL26_28_0_, claimt0_.CL_PACKAGING_PRESENTED_IND as CL27_28_0_, claimt0_.CL_MAILING_DATE as CL28_28_0_, claimt0_.CL_ACCEPTED_DATE as CL29_28_0_, claimt0_.CL_SIGNED_DATE as CL30_28_0_, claimt0_.CL_TOTAL_CLAIMED_AMT as CL31_28_0_, claimt0_.CL_POSTAGE_PAID_AMT as CL32_28_0_, claimt0_.CL_INS_REG_COD_AMT as CL33_28_0_, claimt0_.CL_OTHER_FEES_AMT as CL34_28_0_, claimt0_.CL_COD_REMIT_TO_SENDER_AMT as CL35_28_0_, claimt0_.CL_ORIGINATION_FINANCE_NBR as CL36_28_0_, claimt0_.CL_ORIGINATING_PO_ZIP_CODE as CL37_28_0_, claimt0_.CL_DAMAGE_CLAIM_NOTES_TEXT as CL38_28_0_, claimt0_.CL_ACCEPT_EMP_FIRST_NAME as CL39_28_0_, claimt0_.CL_ACCEPT_EMP_LAST_NAME as CL40_28_0_, claimt0_.CL_ACCEPT_EMP_TELEPHONE_NBR as CL41_28_0_, claimt0_.CL_APPROVE_AUTH_FIRST_NAME as CL42_28_0_, claimt0_.CL_APPROVE_AUTH_LAST_NAME as CL43_28_0_, claimt0_.CL_APPROVE_AUTH_SIGNED_DATE as CL44_28_0_, claimt0_.CL_ACCEPT_EMP_PO_ZIP_CODE as CL45_28_0_, claimt0_.CL_DIS_ARTICLE_CITY_NAME as CL46_28_0_, claimt0_.CL_DIS_ARTICLE_ZIP_CODE as CL47_28_0_, claimt0_.CL_DIS_ARTICLE_TELEPHONE_NBR as CL48_28_0_, claimt0_.CL_DAM_ARTICLE_LOCATION_IND as CL49_28_0_, claimt0_.CL_COMMENTS_TEXT as CL50_28_0_, claimt0_.CL_ADJUDICATOR_USER_ID as CL51_28_0_, claimt0_.CL_VALIDATOR_USER_ID as CL52_28_0_, claimt0_.CL_SERVICE_LEVEL_MET_IND as CL53_28_0_, claimt0_.CL_SEND_TO_CSS_IND as CL54_28_0_, claimt0_.CL_LAST_PROCESSED_DTM as CL55_28_0_, claimt0_.CL_NEXT_SCHEDULED_PROCESS_DTM as CL56_28_0_, claimt0_.CL_SEND_TO_ICIO_IND as CL57_28_0_, claimt0_.CL_SEND_TO_GXG_IND as CL58_28_0_, claimt0_.CL_SEND_TO_BM_IND as CL59_28_0_, claimt0_.CL_INPUT_VENDOR_BATCH_ID as CL60_28_0_, claimt0_.CL_ONLINE_INS_FEE_AMT as CL61_28_0_, claimt0_.CL_OLI_CLAIM_AMT as CL62_28_0_, claimt0_.CL_OLI_ORIGIN_ZIP_CODE as CL63_28_0_, claimt0_.CL_OLI_DELIVERY_ZIP_CODE as CL64_28_0_, claimt0_.CL_OLI_MAILING_DATE as CL65_28_0_, claimt0_.CL_OLI_STATUS_DATE as CL66_28_0_, claimt0_.CL_LAST_SENT_TO_PTS_DTM as CL67_28_0_, claimt0_.CL_SOURCE_CLAIM_ID as CL68_28_0_, claimt0_.CL_LAP_DATE as CL69_28_0_, claimt0_.CL_LAP_MO_NBR as CL70_28_0_, claimt0_.CL_LAP_AMT as CL71_28_0_, claimt0_.CL_LAP_PAID_IND as CL72_28_0_, claimt0_.CL_LAP_DENIED_IND as CL73_28_0_, claimt0_.CL_LAP_DENIAL_REASON as CL74_28_0_, claimt0_.CL_EBAY_AUCTION_NBR as CL75_28_0_, claimt0_.CL_CNS_TXN_NBR as CL76_28_0_, claimt0_.CL_EREG_CRID as CL77_28_0_, claimt0_.CL_CJ_CODE_FK as CL78_28_0_, claimt0_.CL_CUR_CODE_FK as CL79_28_0_, claimt0_.CL_AUTHORIZATION_CODE as CL80_28_0_ from CICRS_CLAIMS.CLAIM_T claimt0_ where claimt0_.CL_ID=?

This query appears to be correctly formed to retrieve all attributes of the specified object. Hibernate continues to repeat this query until the application is stopped manually in the task manager. Does anyone know why Hibernate would enter such an infinite loop? More importantly, is there any way to keep it from doing so? Any information would be most appreciated. Thank you.


Top
 Profile  
 
 Post subject: Re: Infinite loop on simple get()
PostPosted: Thu Jul 16, 2009 12:30 pm 
Newbie

Joined: Mon Jun 29, 2009 5:29 pm
Posts: 3
I traced the get() method through as much of the Hibernate source code as I could manage, but I still can't figure out what would cause a query to repeat ad infinitum. Does anyone have any ideas on this?


Top
 Profile  
 
 Post subject: Re: Infinite loop on simple get()
PostPosted: Fri Jul 17, 2009 4:07 pm 
Newbie

Joined: Mon Jun 29, 2009 5:29 pm
Posts: 3
Situation resolved. For some reason, someone put lazy=false as an attribute of a set in one of the mapping files, causing Hibernate to attempt to load all 10,000 entities in that set. Not actually an infinite loop, but running essentially the same query 10,000 times gave that impression.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.