4 Replies Latest reply on Jul 26, 2004 11:56 AM by albertok

    refreshing entity beans

    ghoyle

      I have a CMP application, where the database can be updated by clients other than the entity beans.
      What I need is a way for the container to know that the underlying database has changed and hence update the entiity beans and then inform a stateful session bean that this has happened. As my clients need to be informed via the session beans when ther has been a change to the database.
      Is there a way to do this with CMP?

      Thanks in adavnce

      Geoff

        • 1. Re: refreshing entity beans
          triathlon98

          This should work as expected "out of the box". You just have to make sure you are using commit option B or C.

          Joachim

          • 2. Re: refreshing entity beans
            ghoyle

            I am not sure what you mean by this.
            The database can be changed using a web interface that does not go through my J2ee app
            I.e. direct database change.
            So how does the entity bean detect this?
            Or more importantly to me, how do I get my stateful session bean to ask the entity bean if the data has changed in anyway?

            Thanks,


            Geoff

            • 3. Re: refreshing entity beans
              ghoyle

              Ok, I realise what you mean by commit levels now.
              I changed the commit level to option D in the standardjboss.xml
              file.
              However my enties are still not being refreshed, if I change the data outside of the the
              container.

              Please see example code, to see if you can see where I am going wrong.

               public void updateTVBS(java.lang.String sessionID, java.lang.String userID){
              
               Collection tvbslist = new ArrayList();
               boolean connected = true;
               TVBSDetails details = null;
               try{
              
              
               ClientDetailsLocal client = clientDetaislHome.findByPrimaryKey(userID);
              
               if(!(client.getUserID() == null) && (client.getSessionID().equals(sessionID))){
               aTvbsList = new ArrayList();
               while(connected == true){
              
               Collection temptvbslist = new ArrayList();
               temptvbslist = client.getTVBSList();
               Iterator i = temptvbslist.iterator();
               while (i.hasNext()) {
               TVBSLocal tvbs = (TVBSLocal) i.next();
               details = new TVBSDetails(tvbs.getIor(), tvbs.getTVBSID().shortValue(),tvbs.getPcoName(),true);
               tvbslist.add(details);
              
               }//while
               if(aTvbsList.equals(tvbslist)){
               System.out.println("In the aTvbsList.equals(tvbslist)");
               // do nothing
               }else{
               try{
              
               System.out.println("Calling back the corba wrapper ");
               callBackRef.callback(tvbslist);
               aTvbsList = tvbslist ;
               System.out.println("The tvbs list size is " + tvbslist.size());
              
               }catch(Exception e){
               connected = false;
               }
               }
               //Sleep for 5 minutes
               //Thread.sleep(300000);
               Thread.sleep(5000);
               }//while
              


              • 4. Re: refreshing entity beans
                albertok

                Option D is rather similar to option A except of bean instances are periodically synchronized at regular intervals, so let's use B or C.