couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Darran White <>
Subject Java Document Object Mapper api
Date Tue, 13 Apr 2010 07:18:38 GMT
I`ve started writing an annotation based couchdb Document Object Mapper
called jBeanbag
The approach I`ve taken is to use 100% annotations so the users domain model
does not have to derive from the api. I`m also trying to make it CouchDB
focused rather
then JSON focused which a few of the other apis seem to be. The aim is to
enable easy mapping to and from CouchDB documents to Java classes and also
provide some infrastructure support
for example @Linked annotation could be above a field meaning the field
should be a linked document and handling conflicts by returning Java objects
of the different versions in an exception.
I`d also like to put in more annotations for other kinds of relationships
like bi-directional.
An example Java annotated class is at the bottom of this mail.

I`m using the ASM library

to create a Meta model of the Java classes ,including all the CouchDB
configuration for that class, is then cached in ehcache and can be reused
for serializing to/from the JSON. The JSON parsing I`m using the the Jackson
JSON Streaming/Mapping apis.
ASM helps by making it easy to analyze the class structure in advance ,using
its visitor pattern, as well as giving access to Generics information.

So I`m looking to the community for any CouchDB patterns they keep repeating
in code which could be included in the framework as well as anyone else who
could be interested in contributing to the code base.

Going forward I`d also like to provide wrappers for Groovy to make it a bit
more ,well Groovier and Scala wrappers.

At the moment theres not a released version but I`m hoping to have a 0.01
version soon. But I have done most of the simple conversion to/from JSON for
sets,Objects, Wrapper Objects e.g Integer class,enums and Dates. Currently
it`ll struggle with things like Arrays of Maps or Lists of Lists but that
should be fixed soon. I`m currently working on the HTTP client side of

Thoughts,comments and especially help all appreciated.



public class Person{
 private String id;

 private String revision

//Will be a list of embedded pet objects in the person document
//not really needed as embedded is the default
 private List<Pet> pets;

//List will be parsed and written as linked documents to this class
 private List<Car> cars;

 private String name;//Will be written as name:<value> in document

 private String dontWriteToDocument; //Won`t be written to the document


  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message