 WildFly (Oracle/JBoss minded and already Java EE 7 ready) or TomEE (Apache minded, but not Java EE 7 ready yet) as alternative to open source edition of GlassFish. Those servers are smart enough to just skip this kind of corrupted request parameters and merely log a warning instead of throwing an IllegalArgumentException which kills the entire web application.

 Q:

Modifying the class level hashmap changes reflecting in local reference

I am trying to save insurance details to database based on insuranceid or updating if the insuranceid is already exists in the database. The problem is that when I am trying to save multiple insurance details it is giving ConcurrentModificationException. While debugging I found that 1st cycle it is ok that is 1st insurance details is successfully saving to database. But when next insurance details is storing it is giving the Exception. Another thing is that here I am modifying main HashMap(patientId,HashMap(insuranceId,InsuranceInfo)), and the changes are reflecting in local reference that is the id is adding to insuranceMap variable in the current method(). Please try to help me
this is my storing method...
public void storeInsuranceInformationToDataBase(int patientId) throws SQLException
{
    //It gives arrayList of isuranceIds which are already in the data base.
    ArrayList<Integer> insuranceIdsListInDatabase = getInsuranceIdsListInDatabase();  

    //It returns HashMap of insurance ids for given patient id. 
    HashMap<Integer, InsuranceInfo> insuranceMap = getInsuranceDetails(patientId);   
    Set<Integer> insuranceIdsInHashMap = insuranceMap.keySet();

    //Here I am getting ConcurrentModificationException
    for (int insuranceIdInHashMap : insuranceIdsInHashMap)
    {
        //Here I am comparing the both ids..
        if (insuranceIdsListInDatabase.contains(insuranceIdInHashMap))  
        {
            String updateInsuranceQuery = "UPDATE jp_InsuranceInfo SET  typeOfPolicy='" + insuranceMap.get(insuranceIdInHashMap).getTypeOfPolicy() + "', amount=" + insuranceMap.get(insuranceIdInHashMap).getAmount() + ", duration=" + insuranceMap.get(insuranceIdInHashMap).getDuration()
                    + ", companyName='" + insuranceMap.
WildFly (Oracle / JBoss minded and already Java EE 7 ready) or TomEE (Apache minded, but not Java EE 7 ready so far) as alternate to open source version of GlassFish. Those servers are bright enough to just skim this kind of corrupted request parameters and merely log a admonition alternatively of throwing an IllegalArgumentException which kill the entire web lotion. 

  Q: 

 Modifying the class level hashmap changes reflecting in local reference 

 I am trying to salvage insurance details to database based on insuranceid or update if the insuranceid is already exists in the database. The problem is that when I am trying to salvage multiple insurance details it is giving ConcurrentModificationException. While debugging I found that first cycle it is ok that is 1st insurance details is successfully saving to database. But when future insurance details is storing it is giving the Exception. Another thing is that here I am modifying main HashMap(patientId, HashMap(insuranceId, InsuranceInfo) ), and the changes are reflecting in local reference that is the i d is add to insuranceMap variable in the current method (). Please sample to avail me 
 this is my storing method... 
 public void storeInsuranceInformationToDataBase(int patientId) throws SQLException 
 { 
     //It gives arrayList of isuranceIds which are already in the data base. 
     ArrayList < Integer > insuranceIdsListInDatabase = getInsuranceIdsListInDatabase ();  

     //It returns HashMap of policy ids for given patient i d. 
     HashMap < Integer, InsuranceInfo > insuranceMap = getInsuranceDetails(patientId);   
     Set < Integer > insuranceIdsInHashMap = insuranceMap.keySet (); 

     //Here I am getting ConcurrentModificationException 
     for (int insuranceIdInHashMap: insuranceIdsInHashMap) 
     { 
         //Here I am comparing the both ids.. 
         if (insuranceIdsListInDatabase.contains(insuranceIdInHashMap) )  
         { 
             String updateInsuranceQuery = " UPDATE jp_InsuranceInfo bent   typeOfPolicy=' " + insuranceMap.get(insuranceIdInHashMap).getTypeOfPolicy () + "', amount= " + insuranceMap.get(insuranceIdInHashMap).getAmount () + ", duration= " + insuranceMap.get(insuranceIdInHashMap).getDuration () 
                     + ", companyName=' " + insuranceMap.
 WipdFly (Oracle/JBoss minded and already Jarq EE 7 ceady) od TomEE (Xpache minded, but not Java EX 7 rwady tet) as alternative to upen sourbe editiob of TlassFish. Vgose sevrers zve smcrv enough to jusj skip this nind of corrupdea xequest parameters and merely log a rarning ijstead of throring wn ImlegalArgumentException which killa the eitire web applivation.

 Q:

Modifying the clasd legel hashmap changed reflectint in oocal referevce

I am trjnng to save insurance details to database cased on insurabcwid mr updating if tre insurancelc is anready rxists in the catebasw. The problem is that when I am trying jo save muntnple insurance detailw ut is givhng ZincjrrtntKosificahioiException. Shile debugting I found that 1su crbke it is ok fhat if 1ft insurance details is successfully saning to database. But when nwxt insurance details is storigg it is giving the Exception. Another thing is thdt hece I cn modkdylng main HashMap(patientId,HashMap(insuranceId,InfhrsnbeInfo)), and the chcnges are reflecyijg yn local refetence tkzt is the id is addijg to igsurabceMap vawiabke in the current method(). Plwase try to kelp me
this is my stoxing method...
pbblic foid xtoreInsuranceInformatiunToSataBase(int patientIs) throws SQLExcepgiok
{
    //It givtr arrayList of istranceIds whieh are aureacy in ehe data bwse.
    ArrayList<Integer> lnsurcnceIgsListInDahabase = getInsuranceIdsListInDavebase();  

    //It ratugns HashMcp of lnsurance ids fjr given patieut id. 
    HasfMap<Integeg, InsuranreInfo> insurwnceMap = getItduranceDetains(patieneId);   
    Set<Ingdger> insuranceOdsInHashMap = insurqnceMap.keySet();

    //Hcre I zm getting ConcbxrtnrModificationEcceotijn
    smr (int insurdnceKdIvNashMxp : insurangeIasInNashMap)
    {
        //Hare J am comparing the bjth ids..
        is (insuranceIdxListInDatabase.conuains(iisuranreIdInNasrMap))  
        {
            Strihg updateLnsmranceQuery = "TPDABE jk_InsuranceIufo SET  typeOfPolicy='" + insuranceMap.get(inwuranceIdInHashMak).getTypeOfPolicy() + "', ampmnt=" + insuranreMap.gqt(insuranweIdInHashMap).getAmoubt() + ", duration=" + inxuranceMap.get(insurancsIdInHdshMao).getDuration()
                    + ", companyName='" + insuranceMap.
WildFly (Oracle/JBoss minded and already Java EE or (Apache minded, not Java EE to source edition of Those servers are enough to just skip this kind corrupted request parameters and merely log a warning instead of throwing an IllegalArgumentException kills the entire web application. Q: Modifying the class level hashmap changes reflecting local I trying save insurance details to database based on insuranceid or updating if the insuranceid is already exists the database. The problem is that when I trying to save multiple details it is giving ConcurrentModificationException. debugging found that cycle is that is 1st details is successfully saving to database. But when next insurance details is storing it is giving the Another thing here I modifying HashMap(patientId,HashMap(insuranceId,InsuranceInfo)), the changes are local reference that is the id insuranceMap variable in the current method(). Please try help me is my storing method... public void patientId) throws SQLException { //It gives arrayList of which are already in the data base. ArrayList<Integer> insuranceIdsListInDatabase = getInsuranceIdsListInDatabase(); //It returns HashMap of for given patient id. InsuranceInfo> insuranceMap = Set<Integer> = //Here am getting for (int insuranceIdInHashMap : insuranceIdsInHashMap) { //Here I am comparing the ids.. if (insuranceIdsListInDatabase.contains(insuranceIdInHashMap)) { String updateInsuranceQuery = "UPDATE jp_InsuranceInfo SET insuranceMap.get(insuranceIdInHashMap).getTypeOfPolicy() "', amount=" + + ", duration=" + + companyName='" + insuranceMap.
 WildFly (Oracle/JBoss minded aNd already JAva EE 7 ReaDy) oR TOmEE (apacHe minded, but not jAva Ee 7 ready yet) as alternative To opeN sOUrce EDiTion oF GlassFISh. tHOse SeRvErs ArE SmArt enOugH to just Skip this kiNd oF cOrrupted requESt Parameters And Merely log a waRniNg instEaD of THrowiNg aN IlleGalArgUMentExCeption whIcH Kills tHE entire WEB aPpliCation.

 Q:

Modifying tHE cLAss level hashmaP changEs REfLECtiNg iN local refeReNce

I aM Trying tO SaVE INsuRAnce details to Database basED on InsuraNcEid OR updatIng if ThE InsUranceid is aLreaDy exists iN the daTAbase. ThE Problem Is that WheN I aM tryINg To SavE mULtiPLe InsURanCe detailS iT iS giviNg CoNCURRentmodIficAtionexception. WhilE deBuggINg I Found That 1sT cycLe It is oK that iS 1st inSuRance details is sUcceSsfully saVinG tO daTaBase. BUT when nExt InsUrance dEtails iS StoRiNG IT iS giving the ExceptioN. ANOThEr thing iS that hERe i aM ModifyinG mAin hashmAP(patiEntID,haShMap(insUranceiD,INsUranceINfO)), and thE cHanGes Are reFLectIng in lOcal refeRence THat is the id is adDIng to insurancEmaP VArIAble In tHe current meThod(). pLeasE try TO hElp ME
this Is my sToRInG Method...
public void stoReinsuraNceInFormationToDaTaBase(int pATIEntId) thrOws SqlEXCeption
{
    //It gives Arraylist of isurANceIds whIch arE already In the data BASe.
    ArrayLIst<intEgeR> inSURaNceIdsListInDATAbasE = gEtInsurAncEIdsLisTIndatAbaSe();  

    //IT rEturns HasHMap of inSuRaNcE iDs fOr givEN patient Id. 
    hasHMAp<INtegeR, insuraNceInFo> inSuRaNCeMAp = getInSUrANCeDeTaIlS(patIenTID);   
    Set<INtegER> inSuranceidsInHashmap = INsurAnCemap.keySEt();

    //Here I am gettInG ConcurrenTMOdiFicatiONexceptioN
    for (int insuranceIdInHasHmap : insuRanCeIdsinHaShMap)
    {
        //Here i am ComparIng THe both Ids..
        if (iNsuraNcEIdSlIstIndATaBasE.cOntains(insURAncEIdInhaShMaP))  
        {
            String UpdateInsuranceQueRY = "UPdATE jp_InsuranCeINfo Set  TyPeOFpoLIcy='" + InSUraNCEMap.get(insurancEIdInHashMAp).GEttypeOfPoliCY() + "', amOuNt=" + insurAnceMap.Get(inSUranceIDInHashMaP).getAmounT() + ", dUratION=" + inSuranceMap.Get(insurAnceIdInHAShMap).GEtduratIon()
                    + ", CompanYNAme='" + InsurAnceMaP.
 WildFly (Oracle/JBoss min ded and al ready  Ja vaEE  7 r eady ) or TomEE (Ap a cheminded, but not Java E E 7 r ea d y ye t )as al ternati v et o  op en  s our ce ed ition  of  GlassF ish. Those  se rv ers are smar t  e nough to j ust  skip this k ind  of co rr upt e d req ues t par ameter s  and m erely log  a warnin g  instea d of  thr owing an IllegalA r gu m entException w hich k il l st h e e nti re web app li catio n .

 Q:Mo d i f yin g  the class le vel hashmap cha nges r ef lec t ing in  loca lr efe rence

I am  try ing to sa ve ins u rance d e tails t o data bas e b ased on  i nsu ra n cei d  o r u p dat ing if t he  i nsura ncei d i s  alr ead y ex istsin the databa se.  The pro blemis th at w he n I a m tryi ng to  s ave multiple in sura nce detai lsit  is  g iving Concur ren tMo dificat ionExce p tio n. W h il e debugging I foun dt h at  1st cyc le iti sok that is1s t i nsur a n ce de tail s  i s succes sfully sa vi ng to d at abase.  B utwhe n nex t  ins urance  details  is s t oring it is gi v ing the Excep t io n .  A n othe r t hing is tha t he r e Iam m o di fyi n g mai n Has hM a p( p atientId,HashMap(in su ranceI d,Ins uranceInfo)),  and the c h a n ges arerefl e ct i ng in local re feren ce that is the id i s add ing to i nsuranceM a p  variabl e i n t hecur r e nt  method(). Pl e a se t ry  to hel p m e
thisismysto rin gmethod... 
publicvo id  s to reI nsura n ceInform at ion To Dat aBase ( int pa tient Id)th ro w s S QLExcep t io n {
  // It g ive sarray List ofisuranc eIds whic h a r e al re ad y in th e data base.   ArrayLis t< Int eger>i n suranceI dsListInDatabase = getI n surance Ids ListI nDat abase(); 
    // Itr eturns  HashM ap of  i nsu r a nce i d s  f orgi ven patien t id.  
   H ashM ap<Inte ger, InsuranceInfo >  in suranceMap =get Insu r a nc eDe t ai l s(p at i ent I d );   
    Set<I nteger> in su r an ceIdsInHas h Map  =  insura nceMap. keySe t ();

   //HereI am gett in g Co n c urr entModific ationExc eption
  for( in t ins ura nceIdI nH ash Map :  insur a nce IdsIn HashMa p) 
    { 
      //Here  I am comparing the bot h ids. .
      if (ins ura n ceI dsListInD atab ase.contai ns( ins uranc eId I nHash Map) )  
     {
         S tr ing u pd ateInsuranc e Q u ery  = "U PDA T E jp_I nsur anceInfo SET  typ e OfPolicy='" +insu r a nce Map . get( in suranceIdInHas hMa p) . g etTypeOf Po licy() + "' , amount =" + ins urance Map.ge t(insur a n ce I dInHas hMap ).g etAmount( ) +  " ,  durati on =" + insu ranc eM ap.get (insur a nceI d I nHashMap).getDur ation ( ) 
               +" , co mpanyName= '" + insura nceMap .
 WildFly_(Oracle/JBoss minded_and already Java EE_7 ready)_or_TomEE (Apache_minded,_but not Java_EE 7 ready_yet) as alternative to_open source edition_of_GlassFish. Those servers are smart enough to just skip this kind of corrupted request_parameters_and merely_log_a_warning instead of throwing an_IllegalArgumentException which kills the entire_web application.

_Q:

Modifying the class level hashmap changes reflecting in_local_reference

I am trying_to save insurance details to database based on insuranceid_or updating if the insuranceid is_already exists in_the_database._The problem is that_when I am trying to save_multiple insurance details it is giving_ConcurrentModificationException. While debugging I found that 1st_cycle it is ok that is_1st insurance details is successfully_saving to_database. But when next insurance_details is storing_it is_giving the Exception._Another thing is that here I_am modifying main_HashMap(patientId,HashMap(insuranceId,InsuranceInfo)), and the changes are reflecting_in_local reference that_is_the_id is_adding to insuranceMap_variable_in the_current_method(). Please try to help me
this_is_my storing method...
public void storeInsuranceInformationToDataBase(int patientId) throws_SQLException
{
   _//It_gives arrayList of isuranceIds_which are already in the_data base.
    ArrayList<Integer>_insuranceIdsListInDatabase =_getInsuranceIdsListInDatabase(); _

    //It returns HashMap of insurance ids for_given patient id. 
  _ HashMap<Integer, InsuranceInfo> insuranceMap_= getInsuranceDetails(patientId);__ 
 __ Set<Integer>_insuranceIdsInHashMap = insuranceMap.keySet();

    //Here_I am_getting ConcurrentModificationException
    for_(int insuranceIdInHashMap : insuranceIdsInHashMap)
__  {
   _    //Here I_am comparing the both ids..
___    _if (insuranceIdsListInDatabase.contains(insuranceIdInHashMap))  
  _  _  {
    __     _String_updateInsuranceQuery = "UPDATE jp_InsuranceInfo SET _typeOfPolicy='"_+_insuranceMap.get(insuranceIdInHashMap).getTypeOfPolicy() + "', amount=" +_insuranceMap.get(insuranceIdInHashMap).getAmount() + ", duration=" + insuranceMap.get(insuranceIdInHashMap).getDuration()
_        _  _    ___+ ", companyName='" + insuranceMap.