2 Replies Latest reply on Feb 16, 2009 5:29 PM by brian.stansberry

    Jboss cache does not synchronize state with DB when manually

      Hi all,

      I have a question/issue. It seems that when I manually insert data into DB(eg, a new user account), the cache does not see the modification, and continue running with data loaded before.

      What is the normal behaviour of the cache, when data is inserted manually, not through persistence context?

      Regards,
      Mihai Ratiu

        • 1. Re: Jboss cache does not synchronize state with DB when manu

          As an update I use Jboss Cache 1.4.0 "Cayenne" and use with EJB3EntityTreeCache Service.

          • 2. Re: Jboss cache does not synchronize state with DB when manu
            brian.stansberry

            The cache is only aware of database changes made through your EntityManager (if you are using JPA) or Hibernate (if not).

            If you add a record manually and then try to read it through the EntityManager, you'll get a database read and thereafter the entity will be cached.

            What's more of a problem is if you manually update an existing database record. Then it's possible the cache will be storing out of date data, since it's unaware of the manual change. If temporarily seeing out of date data is OK, you can configure JBC eviction and add a max-age config to ensure the stale data eventually gets dropped from the cache.

            But generally speaking, using a second level cache is not a great idea if an external process will be modifying the database.