I was wondering if it is possible to use the CacheLoader and CacheWriter interfaces to create a persistence store that uses a current relational database.
Let's explain a bit more:
- We have a relational database with some tables
- We would like to use Infinispan to leverage its high availability and speed, but we would also like to keep the current database schema as it is consumed by other applications (not written to!)
The first idea was to just use the Hibernate 2nd level cache, but if the database is down, then we wouldn't have (part of) the data anymore and updates wouldn't be pushed to the database/be impossible. So now we are thinking of using Infinispan as it supports a write-behind mechanism, where we can keep functioning if the database would be down and push changes to the database once it's back up again.
If we write a custom loader/writer, it should be possible, but I think it would be very difficult. Unless maybe we can use our current hibernate configuration on this loader/writer to handle the ORM part of it?
Anybody who has an idea if this is possible? Maybe it's discouraged? Maybe someone already has done something similar to this?
the JPA Cache loader might help you do this. And then configure it to be async would enable write behind. Node that the async store would keep stuff in memory though, so you'd need to restart your DB at some point.