Return-Path: Delivered-To: apmail-struts-user-archive@www.apache.org Received: (qmail 70560 invoked from network); 31 May 2008 20:24:09 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 31 May 2008 20:24:09 -0000 Received: (qmail 68544 invoked by uid 500); 31 May 2008 20:24:00 -0000 Delivered-To: apmail-struts-user-archive@struts.apache.org Received: (qmail 68533 invoked by uid 500); 31 May 2008 20:24:00 -0000 Mailing-List: contact user-help@struts.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Struts Users Mailing List" Reply-To: "Struts Users Mailing List" Delivered-To: mailing list user@struts.apache.org Received: (qmail 68522 invoked by uid 99); 31 May 2008 20:24:00 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 31 May 2008 13:24:00 -0700 X-ASF-Spam-Status: No, hits=2.0 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of marcio.rga@gmail.com designates 209.85.198.238 as permitted sender) Received: from [209.85.198.238] (HELO rv-out-0506.google.com) (209.85.198.238) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 31 May 2008 20:23:12 +0000 Received: by rv-out-0506.google.com with SMTP id b25so299813rvf.47 for ; Sat, 31 May 2008 13:23:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; bh=7eTJPZ1KYfaSkYU3vtXtvNrxvXqV9M/UW6l5lYoA/LI=; b=bnOssBtv6WopqHFIsgXHiTZDxeLufjrz9g7l3Lc0EJPFkag/Hx1LqqP/1cE7KVCQ2qWaQ9F30riCYPv8cpuzoozFg3PGuosJtS/uzs541pFfrJBe+dx4vrJ9HusAQF1HGcuBrOgbmk4sQtU5H16Axj0E0XMGhO9BbnBy/C6nKEY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=SPr3D6eonBxtw19enIvEESVf4c5WvysW60NLTU8ABPoVJz4LravcCd4wOLyvxLP9p8xPOPt8/rVWUa6vDwQAbmIFh5CoJbtJ1L28ljrBrgjMwJyNTPgAE6m8VTs66gFRvtsRUrSav2hqO+roDpOFgzPMDmoCFR20bJ810+m54qQ= Received: by 10.141.15.19 with SMTP id s19mr3927658rvi.161.1212265408613; Sat, 31 May 2008 13:23:28 -0700 (PDT) Received: by 10.141.205.15 with HTTP; Sat, 31 May 2008 13:23:28 -0700 (PDT) Message-ID: Date: Sat, 31 May 2008 17:23:28 -0300 From: "=?ISO-8859-1?Q?M=E1rcio_Gurgel?=" To: "Struts Users Mailing List" , marcio.rga@gmail.com Subject: Re: Struts 2 + Hibernate question [RESOLVED] In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_18215_23537430.1212265408608" References: X-Virus-Checked: Checked by ClamAV on apache.org ------=_Part_18215_23537430.1212265408608 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Uh Oh... It's not really ok... After I update a object from a jsp all field are shown in the current jsp ok, but when I'm comming from a link (searh a object) are displayed the old state (before update). /: Now I just dont know what to do. Seems that struts still caching my object. I have to run against the time, I have to present my final academic project next month. Any ideias? I'm really needing a hand. M=E1rcio Gurgel 2008/5/30 M=E1rcio Gurgel : > I guess that this is the end of my saga. > > Stewart showed me the way and I resolve this by calling the method to ope= n > data. > Before I was calling this method via redirectAtion, now I just call by my > action class and just like magic everything went well. > * I changed my result to return a jsp not a action. > > Thanks so much to: Sutton, Dusty, Stewart, Owen and Martin. I hope help y= ou > also in another opportunity! > > Here's the code: > > ---- ACTION TO UPDATE ---- > * After update I called setValuesAbrirPageFsc to populate my view (mainly > autocomplers and s:selects) > > public String alterarFsc(){ > try { > String[] telefones =3D new String[]{telefone1, telefone2, > telefone3, telefone4}; > Integer[] cdsTipTel =3D new Integer[]{cdTipoTelefone1, > cdTipoTelefone2, cdTipoTelefone3, cdTipoTelefone4}; > getClienteFacade().alterarFsc(clienteFsc, getUsuarioLogado(), > cdSitCliente, telefones, cdsTipTel, cdCidadeKey); > > > setClienteFsc(clienteFsc); > > //HERE I CALL THE MENTIONED METHOD > setValuesAbrirPageFsc(); > > } catch (Exception e) { > addActionError(SgvdbaConstants.ERRO_DEFAULT + e.getMessage())= ; > return Action.INPUT; > } > return Action.SUCCESS; > } > > > ---- POPULATES A JSP ---- > private void setValuesAbrirPageFsc(){ > if (clienteFsc !=3D null){ > if (clienteFsc.getCd() !=3D null){ > clienteFsc =3D > getClienteFacade().recuperarFscPorId(clienteFsc.getCd()); > clienteFsc.setCep(MaskUtil.maskCep(clienteFsc.getCep())); > clienteFsc.setCpf(MaskUtil.maskCpf(clienteFsc.getCpf())); > setQtdTelefones(clienteFsc.getTelefones().size()); > > int i =3D 0; > List telefoneList =3D > getTelefoneFacade().recuperarPorCliente(clienteFsc.getCd()); > for (Iterator it =3D telefoneList.iterator(); > it.hasNext();){ > Telefone telefone =3D (Telefone) it.next(); > switch (i) { > case 0: > telefone1 =3D > MaskUtil.maskTelefone(telefone.getNumTel()); > valueTipoTelefone1 =3D > telefone.getTipoTelefone().getCd(); > break; > case 1: > telefone2 =3D > MaskUtil.maskTelefone(telefone.getNumTel()); > valueTipoTelefone2 =3D > telefone.getTipoTelefone().getCd(); > break; > case 2: > telefone3 =3D > MaskUtil.maskTelefone(telefone.getNumTel()); > valueTipoTelefone3 =3D > telefone.getTipoTelefone().getCd(); > break; > case 3: > telefone4 =3D > MaskUtil.maskTelefone(telefone.getNumTel()); > valueTipoTelefone4 =3D > telefone.getTipoTelefone().getCd(); > break; > } > i++; > } > } > > } > } > > > 2008/5/30 M=E1rcio Gurgel : > >> Hi! >> >> Tanks Stewart and Owen! >> >> Stewart, I tried by unit test case, and everything went well. >> I guess that you discovered the reason of the problem (: >> >> As you saw, after update I call another action (redirect) to show the >> data. >> Now I tried to return a JSP as result, and the problem went away. >> In fact the value stack from struts 2 are getting the old object state. >> But I need to use redirectAction. Do you have any idea? >> >> You made some questions here are the answers (: >> >> "are both actions still on the stack, or just the last one to run?" >> - Honestly I dont know... >> >> "One question - how are you committing your database changes?" >> - Every database operation to update a object is inside a session.begin(= ) >> and after session.commit() and session.flush() >> >> Could the commit not be happening until after you try to get the updated >> object? You mentioned doing a refresh and flush - shouldn't you do a flu= sh >> and commit first, and then the refresh? >> - By debugging, I sow that after the update the comit() method is aways >> called. >> I also tried to flush the session before bringing the object from >> database, no success too. >> >> >> Thanks so much for your help and atention. >> >> M=E1rcio Gurgel >> >> >> 2008/5/30 Owen Berry : >> >> If you get Hibernate to log your queries, you can watch your log file an= d >>> make sure that Hibernate is actually executing a select statement when >>> you >>> hit that page. If it's not, then it's definitely not Hibernate. >>> >>> On Thu, May 29, 2008 at 1:25 AM, M=E1rcio Gurgel >>> wrote: >>> >>> > Hi all! >>> > >>> > I'm using struts 2 + hibernate. >>> > I've a strange problem, if someone could give me a hand I'll be so >>> > tankfull. >>> > >>> > If I persist a object in my app every things go well and all >>> relationchips >>> > are stored correctey correctly. >>> > The problem occours when I update this object... After the update all >>> data >>> > are stored correctly too, but the problem is that my page shows the o= ld >>> > object (different from database). >>> > >>> > This could be some kind of cash from struts 2? Or my problem is just >>> > hibernate? >>> > >>> > I tryed this methods to force a refresh after bring the object from >>> > database >>> > session.refresh(obj) >>> > session.flush() >>> > >>> > Tank so much for attention! >>> > >>> > M=E1rcio Gurgel >>> > >>> >> >> > ------=_Part_18215_23537430.1212265408608--