Ray Hooker
2014-01-24 20:49:20 UTC
I was looking for tips on working with MongoDB and embedded documents with
Spring Roo. I am also to other approaches. As you know, MongoDB is
document oriented and the power is when a document has subdocuments
embedded. For example in the healthcare field, there are patient documents
export formats (C32, CCDA) that include a snapshot of the data in a single
XML document. The question is how to work with these complex documents in
Spring Roo.
The examples I have seen for MongoDB, Spring Data and Spring Roo all lead
to separate documents. What is needed is to have the entities referenced
in a one-to-many relationship where the data is actually retrieved from the
single large document returned. So accessing the subdocuments only
requires parsing and not database reads. So for example, I could define an
entity Record that has a field such as:
field reference --fieldName medications --type ~.domain.Medication
--cardinality ONE_TO_MANY --class ~.domain.Medication
If I were writing the code say using the native MongoDB driver, the
document would be returned as a BasicDBObject. The record DAO for patient
would simply get the "medications" key that would return a list of
BasicDBObject's, each containing the data for a medication DAO.
So is there a way to get JPA/ Spring Roo to generate the repositories for
these subdocuments so that they are retrieved from the parent document and
not from MongoDB as a separate document? This is easy to do with Rails/
Mongoid, but I can't see how to do it with Roo. Grails is a possibility if
it has the support. Hopefully both can do it, even if the intro docs do not
show how.
Thanks,
Spring Roo. I am also to other approaches. As you know, MongoDB is
document oriented and the power is when a document has subdocuments
embedded. For example in the healthcare field, there are patient documents
export formats (C32, CCDA) that include a snapshot of the data in a single
XML document. The question is how to work with these complex documents in
Spring Roo.
The examples I have seen for MongoDB, Spring Data and Spring Roo all lead
to separate documents. What is needed is to have the entities referenced
in a one-to-many relationship where the data is actually retrieved from the
single large document returned. So accessing the subdocuments only
requires parsing and not database reads. So for example, I could define an
entity Record that has a field such as:
field reference --fieldName medications --type ~.domain.Medication
--cardinality ONE_TO_MANY --class ~.domain.Medication
If I were writing the code say using the native MongoDB driver, the
document would be returned as a BasicDBObject. The record DAO for patient
would simply get the "medications" key that would return a list of
BasicDBObject's, each containing the data for a medication DAO.
So is there a way to get JPA/ Spring Roo to generate the repositories for
these subdocuments so that they are retrieved from the parent document and
not from MongoDB as a separate document? This is easy to do with Rails/
Mongoid, but I can't see how to do it with Roo. Grails is a possibility if
it has the support. Hopefully both can do it, even if the intro docs do not
show how.
Thanks,
--
Ray Hooker
Ray Hooker