, , ,

1.      We have a system in which 2 applications share the same database instance. Application 1 uses BC4J, while Application 2 uses Toplink/JPA. Because of the Toplink cache, all the changes persisted to DB done by Application 1 is not recognized by Application 2, unless we bounce the Application 2 server, or we wait for a long time. I guess this is a common problem that others encountered before. Please share your advice on this problem.

2.       We are running macro’s through an excel sheet that connects to the database and performs Updates and Inserts.
Since this database update is NOT taking place through TopLink (in a Unit of Work) – we do not see the database changes through the web app on the front end unless we bounce our webserver. Presumably the Toplink cache is re-built on start up…so then we can see the changes.
My question is, what can I do to make sure the TopLink cache is aware of the database changes we have made through the macro without having to bounce the server? Is there a re-fresh or sync command that can be run?
This task is sort of a one time thing, so I don’t want a solution that involves the cache going to sync itself on a schedule or anything like that. Maybe bouncing is the best solution?

3.       We have 2 apps, 1 of those is using vanilla JDBC[1,2,3,4] driver to update the database with a status flag, say “completed” and another is using JPA to read that every 5 seconds and update some status on UI accordingly. But the second one is not getting updated data event if the first one successfully committed some change to the db until we bounce the second app or de-hydrate/hydrate object graph from with some other means.

These are some common questions those I have found to fly around several forums or community sites of popular ORM tools.

The problem is lying on the lack of our technological understanding about ORM and even JDBC. Neither the JDBC specification nor any ORM specification which exists on top of JDBC spec provides application level notification in case of any data modification under the hood of native database layer. So your application will be unaware of any such change unless you are doing any of the CRUD operation at native database layer.

Wait.. wait.. I can hear some voices there.. “If we clear the cache, then?”

Well, when you are clearing your cache that means on very next  Read operation your data will be fetched from native database layer which is conforming my previous statement, so, you will be able to get modified data.

The very next question that I usually face is “Then, should we use cache in such environment where multiple apps are performing CRUD operations on a database?”

Good question! I shall write on this on my next blog, but what do you think? What’s your suggestion?

Feel free to comment pr put your questions in this blog. I shall love to have brainstorm.

You can directly reach me back with Gmail/gtalk at puspendu.banerjee