Tags
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