We’ve seen about all mongodb operations those can be performed using java. We wrote java code which interacts with java driver directly and performs operations in mongodb. By this way we have to directly deal with collections and all the fields within it. As we are java developers, it would have been great if there was some framework in mongodb just like JPA or Hibernate in relational databases, and guess what , there is such framework. We will get some introduction to morphia.
Introduction to Morphia:
Morphia acts as a layer between application logic and mongodb database. As java developers it is easier for is to directly deal with POJO classes than with documents in collection. Introduction to morphia will list out such parameters why morphia is useful.
- Provides way to map documents to java classes
- Easier for java developers to deal with POJO than with documents directly.
- Errors due to mismatch of fields in documents while programming can be avoided.
- Provides another way to query documents (in the form of entities) from mongodb
- POJO classes defined as entities on which operations can be performed
- Another layer of separate adds flexibility.
This is just an introduction to morphia. we will see how things work in it form next tutorial onwards