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

    refreshing entity beans

    ghoyle Newbie

      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


        • 1. Re: refreshing entity beans
          Joachim Van der Auwera Expert

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


          • 2. Re: refreshing entity beans
            ghoyle Newbie

            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?



            • 3. Re: refreshing entity beans
              ghoyle Newbie

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

              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;
               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);
               System.out.println("In the aTvbsList.equals(tvbslist)");
               // do nothing
               System.out.println("Calling back the corba wrapper ");
               aTvbsList = tvbslist ;
               System.out.println("The tvbs list size is " + tvbslist.size());
               }catch(Exception e){
               connected = false;
               //Sleep for 5 minutes

              • 4. Re: refreshing entity beans
                Albert Dabrowski Newbie

                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.