Hibernate Books

All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: JDBC/JPA based cache loader for Infinispan
PostPosted: Tue Sep 27, 2011 10:29 am 
Newbie

Joined: Tue Mar 04, 2008 10:37 am
Posts: 6
Hello,
I am wondering if there are any plans for implementing a cache loader for Infinispan which uses JPA annotations to load/store the cache content to a relational database.

The use case which I have in mind is an application which loads on startup most of the model into its memory. To guarantee Height Availability the application needs to run an multiple nodes. Therefore all data has to be put into a distributed cache like Infinispan. OGM/Infinispan sounds promising for this purpose since we already have some experience using JPA.

Since we still want to store the data in a relational database it would be nice to have a cache loader which updates the database by using the JPA annotations. The available cache loader (JdbcBinaryCacheStore,JdbcStringBasedCacheStore and JdbcMixedCacheStore) do not look like a good solution for this purpose.


Do you think it is a wrong use case for Hibernate OGM? Would it be smarter to user Hibernate as JPA provider and Infinispan as second level cache?

Thanks for any input,
Cheers Tim


Top
 Profile  
 
 Post subject: Re: JDBC/JPA based cache loader for Infinispan
PostPosted: Wed Sep 28, 2011 5:37 pm 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2296
Location: Third rock from the Sun
Hi,
there's this issue open since some time: https://issues.jboss.org/browse/ISPN-31
but it doesn't look like it would fit what you're looking for.

When using Hibernate with Infinispan as a second level cache this is usually configured with cluster mode "invalidation", but you could certainly configure it instead as "distribution" or "replication", that would give you some degree of availability for a limited set of read-only operations. Writing transactions would still need to connect to the database with such a configuration, and that's where OGM becomes interesting.

the problem with implementing an Infinispan CacheLoader is that it stores data in a "map" API, so you would receive keys and values. I guess one could implement a trivial JPA based cache loader which stores everything in a simple table having a key and a value column (and that's what is about ISPN-31 as far as I understood), so the only difficulty would be to implement the value with a large enough @Blob.

I guess what you really want is to store the values in a structured form? I'd try OGM in that case, and have it persist via a JdbcStringBasedCacheStore in a database for non-volatile storage. Keep in mind OGM is currently in development and while the CRUD operations are fine there are some limitations on which queries it can support.

Quote:
To guarantee Height Availability the application needs to run an multiple nodes. Therefore all data has to be put into a distributed cache like Infinispan.

did you consider the "standard" alternatives, like using a relational database in a failover configuration?

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
 Post subject: Re: JDBC/JPA based cache loader for Infinispan
PostPosted: Thu Sep 29, 2011 12:39 pm 
Newbie

Joined: Tue Mar 04, 2008 10:37 am
Posts: 6
Hi,
thanks for the detailed answer. I already had a look at ISPN-31. But I think what I am looking for is a slightly different cache store. The idea behind it is to have the data stored as if we used Hibernate JPA instead of Hibernate OGM. So the cache store needs to update the right table/row depending on the information of the map key and/or information gained from the JPA annotations. I know that it won't be easy to implement something like that, but it would enable each application which uses JPA to be turned into a distributed application simply by using Hibernate OGM, Infinispan and the new cache store :-). If that could be done in a well performing way it would certainly push Hibernate OGM.

Quote:
Writing transactions would still need to connect to the database with such a configuration, and that's where OGM becomes interesting.

Good point. That is the reason why we consider to use OGM. It takes also care of the cache updates and will (hopefully) be faster in doing so (since it is crucial for OGM to update the NoSQL store (in our case the distributed 2nd level cache).

Quote:
did you consider the "standard" alternatives, like using a relational database in a failover configuration?

Yes, but we can not do that since the start of our server application takes quit a while (about 30 min). As already mentioned we keep our whole business model in the main memory (and it turned out that we can not easily change that :-()


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.