Search code examples
javacouchdbektorp

Java data access to CouchDB: ORM or REST?


I'm working on an application acts as an event service bus for integrating various legacy components....The application utilizes a data store to audit all events and requests sent between systems as well as to store metadata about bus-subscribing endpoints...etc. I want to utilize CouchDB as the data store since it already has many of my application's requirements built-in (REST API, replication, versioning metadata documents...etc). Now here's how my app stack looks like:

  [spring-integration filters/routers/service activators]
  [service layer]
  [dao layer]
  [database]

With the database being CouchDB, I guess the the DAO layer would be either Ektorp Java library or a simple REST client. Here's my question though: isn't building a DAO layer with Ektorp kind of redundant? I mean, why not just use a RestTemplate in the service layer that talks to the views and design documents in CouchDB and save me some coding effort?

Am I missing something?

Thanks,


Solution

  • If you roll your own you will have to implement the json parsing / mapping of view results and what not.

    Besides efficient view result parsing / object mapping which might be tedious to develop yourself, Ektorp will also help you with view design document management through annotations.

    Ektorp has many more features that I think you will appreciate when you dive deeper into CouchDB.

    If your app only will perform simple gets of individual documents, then rest template might be enough. Otherwise I don't think you will safe time doing it yourself.