It's already 18 hours that i'm playing with Spring framework. It's beautiful, really开发者_Go百科 amazing. As far as i can see spring knows how to work rdbms databases .
Can anyone tell me about experience of spring + NoSQL ( cassandra , couchdb\mongodb, redis or even HBase ) ?
thanks
For Cassandra you can use Hector. It has a usable spring integration (implemented by me). In the test resources there is an example xml - you just map 3 beans, and you have your HectorTemplate
injecected and ready to work with.
For everything else - you said spring is beautiful, and it indeed is, because you can use almost any API with it, without the API specifically adhering to or depending on spring.
If you want to use Redis, you can check Jedis http://github.com/xetorthio/jedis (which is a Java client for Redis). If you are using Grails (a groovy framework on top of Spring) you can use GORM for Redis http://www.grails.org/plugin/redis as a persistence framework for Redis. And if you want to stick to java and use redis with a persistence framework, you can use JOhm http://github.com/xetorthio/johm
I'm assuming you mean similar to JDBCTemplate. If so, there's no template based functionality that supports the NoSQL crowd as a whole. You'd either need to build your own on top of a client for that NoSQL client. Cassandra, for example has a number of clients written by various people:
http://wiki.apache.org/cassandra/ClientOptions
You might get lucky with specific NoSQL databases, it appears someone is working on a Cassandra4Spring framework:
http://code.google.com/p/workingonit/wiki/Cassandra4Spring
For Cassandra you can use datastax driver or Hector Framework
For mongoDb you can use spring data(see example http://www.mkyong.com/mongodb/spring-data-mongodb-insert-document/). You can also use hibernate as OGM for mongodb(see example http://pragmaticintegrator.wordpress.com/2011/07/14/use-spring-and-hibernate-with-mongodb/)
For Redis you can use spring data. You can see my post for full example how to store an image to redis using java / spring
I deployed a project in production with EasyCassandra, which is written on top of Spring Data JPA.
However, EasyCassandra has not been evolved since September 2014.
However, with the experience gained, I used Spring Cassandra in another totally different project. The result is amazing. And I removed the fluff with Spring Data JPA. Using QueryBuilder API in Spring Cassandra is actually much easier. Simple queries you can use Spring Data JPA, but when things get complicated, you may end up finding query builder is more straight forward and less mapping heavy.
精彩评论