2 Replies Latest reply on Jan 28, 2011 4:42 AM by vata2999

    getPreviousInstance() from EntityHome

    vata2999

      Hi,
      i created a component bean extends EnittyHome when i update an entity
      i want to getPreviousInstance before update without hit the database
      how can i achieve this ?


      when i click on edit link wire method return the instance that i want to, however i could not preserve it until update is it good idea to hold it into pageContext ?




      getPageContext.set("prevInstance",getInstance());





        • 1. Re: getPreviousInstance() from EntityHome
          monkeyden

          It's still the same instance so modifications to the object's properties will still be seen.  You likely have to copy it, which can be cumbersome with an object graph.

          • 2. Re: getPreviousInstance() from EntityHome
            vata2999

            I face sth wierd even after i load entity from database all the object value bind to new
            instance



            @End
            public String update(){
            MadeLicense prevMl = (MadeLicense)getEntityManager().createQuery("from MadeLicense ml where mlid = :mlid")
            .setParameter("mlid",getIstance().getId()).getSingleResult(); // this return new instance
            MadeLicenseLog mlLog = new MadeLicenseLog();
            BeanUtils.copyPropeties(prevMl, mlLog);
            super.updated();
            }