3 Replies Latest reply on Apr 1, 2007 11:39 PM by mikolg

    Invalidate cache for an Entity Bean?

    sonu131

      I have an entity bean which is marked as NonShared with commit option A. a new backend application is coming up which can update the data via direct jdbc calls. this happens rarely but when that will happen my entity bean if already cached will get out of sync with the change updated .
      I have two options here.

      1. Make the entity bean shared so that it can come in sync with database.
      2. Stop updating via direct jdbc calls, go via ejb only.

      But I am thinking, if
      I can invalidate the cache for that particular bean through an api call But do not know how to do it or there is some other better option?

      My Jboss is in non-cluster mode.

      thanks.

        • 1. Re: Invalidate cache for an Entity Bean?
          mikolg

          Hello sonu131

          Did you find a solution?

          • 2. Re: Invalidate cache for an Entity Bean?
            sonu131

            No, I did not find any solution so far. was looking at some of others queries/answers here but did not get any idea wether it is possible or not.

            • 3. Re: Invalidate cache for an Entity Bean?
              mikolg

              Hi
              I removed entity bean (ejb2) from the cache in the following way:

              rmiAdaptor = (RMIAdaptor) context.lookup("jmx/invoker/RMIAdaptor");

              rmiAdaptor.invoke(new ObjectName(
              "jboss.j2ee:jndiName=ENITITY-BEAN-JNDI,plugin=cache,service=EJB"),
              "remove", new Object[] { id },
              new String[] { "java.lang.String" });


              just change ENITITY-BEAN-JNDI to your name.

              Note: check that the following service extists in the jms-console
              "jndiName=ENITITY-BEAN-JNDI,plugin=cache,service=EJB"