The Basics - logitopia/jmortar-core-persistence GitHub Wiki

This persistence library allows you to easily create data access objects (DAO) for your POJO models that you want to persist.

Data Access Object (DAO)

The data access object is the entry point for the rest of your system to perform persistent operations for a given model. Each model has it's own DAO.

The DAO is broken up into two "components". The first is a readable data access component and the other is a writable data access component. These allow us to enforce a DAO as read or write only as we see fit when configuring our DAO.

Data Access Component (DAC)

The DAC allows us to compartmentalise the read and write persist operations. It makes the code more maintainable, whilst making it far easier to enforce global restrictions on read and write operations. If, for example, we only want to be able to read data for a given model. Normally we would have to code in a permission system for our DAO. In the interests of keeping it simple, in this system, all of you have to do is omit a writable DAC for the DAO. Easy!

Model

This is your ordinary POJO that you want to store in the database or datastore. Depending on how you want to set up your implementation depends on how you want to set this model up. You can define your DAO and DAC using ordinary spring beans, in which case there is no need to have anything in the model.

There is an easier way though! You can annotate your model and then just lean on the builders to initialise all of the data access beans you need!

Summary

That's it! There are some other classes called builders, but you don’t need to worry about them. They are there to help out and create DAC and DAO for you if you annotate your models.

The only other thing you need to configure is your data source (see examples of these below). Again, if your using the scanner then these are pretty straight forward, all you need to do is either specify the beans with specific names OR specify them on your model annotation.

This covers the basic theory behind how the library works. Now, don’t take my word for it! Try out some of the tutorials below.

Compatibility Matrix

The compatibility matrix below shows which persistence mechanisms are supported by JMortar's persistence module.

Name Read Write
Hibernate yes yes
DynamoDB yes yes