the domain model
In longevity, we use the term domain model to describe the classes you want to persist.
There are two basic approaches you can take to describe your domain model to longevity:
- marking the classes you want to persist with annotations, or
- providing companion objects for your classes that describe how you want to persist them.
We recommend you use the annotations-based approach, as it decidedly
cuts down on boilerplate code. These annotations are actually
macros,
so you will need to include this line in your build.sbt
to use them:
addCompilerPlugin("org.scalamacros" % "paradise" % "2.1.0" cross CrossVersion.full)
Everything you can do with the annotations, you can do with the descriptor companion object approach as well. The examples in this user manual will favor the annotations approach, but we will include the equivalent companion object version every time a new annotation feature is presented.
In this chapter, we will first look at how you can build all the
elements of your domain model. In the final section, we will see how
to gather all of these elements into a
longevity.model.DomainModel
. Here’s an overview: