Something tier that implements its persistence according to JPA can profit greatly in the second-level cache that's handled transparently through the JPA provider (e.g. Hibernate, Toplink/Toplink Necessities etc.). If this cache is triggered, it holds cases of the persistent classes the moment these were loaded in the database the very first time. There might be vendor-specific extensions to configure the cache behavior.

The JPA standard will also support positive securing by getting a timestamp or version area that's accustomed to avoid data corruption when concurrent updates occur. Because this mechanism depends on the information included in the database it is also used when other programs or services wish to update the information - just range from the version area from the record within the update and you are done.

If this involves caching, the behavior appears to become that the JPA provider (a minimum of Toplink Necessities) doesn't notice alterations in the database that are not carried out while using EntityManager.

Is truly the default behavior and also the responsibility to update/invalidate the JPA provider cache can be the applying? If so, this appears quite counter-intuitive that most databases are used by lots of different programs.

This behavior often happens for Hibernate (19.2. The Second Level Cache):

Remember that caches do not know changes designed to the persistent store by another application. They are able to, however, be set up to regularly expire cached data.

This sounds reasonable. How when your cache learn about any changes made by another application if that one does not make use of the cache? The only real possibility left for that cache/JPA provider is always to monitor the database (all tables, all data) for changes increase accordingly. This is not really achievable.

I have also read it's strongly frustrated to make use of the 2nd-level cache when multiple programs alter the same data within the database, for that above pointed out reasons.