I am experimenting a lot these days, and one of the things I wanted to do was combine the two popular NoSQL databases, namely Neo4j and MongoDB. Just because I feel that they complement each other perfectly. First-class citizens in Neo4j, relationships, are exactly what is missing in MongoDB, while MongoDb allows me not to put large amounts of data in my node properties.
So, I'm trying to combine the two in a Java application using the Java REST Neo4j binding and the Java MongoDB driver. All my domain objects have a unique identifier, which I store in both databases. Other data is stored in MongoDB, and relationships between objects are stored in Neo4J. For example, both databases contain a user ID, MongoDB contains profile information, and Neo4J contains friendships. With the user level data access I wrote, this works exactly the way I want. And it's fast.
BUT ... When I want to create a user, I need to create both a node in Neo4j and a document in MongoDB. Not necessarily a problem, except that Neo4j is transactional and MongoDB is not. If both were transactional, I would just roll back both transactions when one of them failed. But since MongoDB is not transactional, I cannot do this.
How can I guarantee that whenever I create a user, either node and Document are created, or none of them. I do not want to end up with a lot of documents that do not have node matching.
In addition, I not only want my combined interaction with the database to be ACID compatible, I also want it to be thread safe. Both GraphDatabaseService and MongoClient / DB are provided from single-network.
I found something about creating "transactional documents" in MongoDB, but I don't like it. I would like something nice and clean, like neo4j beginTx, tx.success, tx.failure, tx.finish setup. Ideally, I can implement try / catch / finally in the same block.
Should I make the switch to CouchDB, which looks transactional?
Edit: After several studies triggered by the comment, I realized that CouchDB is also not suitable for my specific needs. To clarify, part of the Neo4j is set in stone. The document repository database is not as long as it has a Java library.