A Persistence Framework for Scala and NoSQL

View project on GitHub

constructing a domain model

Now that we’ve built out the elements of our domain model, we need to collect them into a longevity.model.DomainModel object. The easiest way to do this is as follows:

package myPackage

import longevity.model.annotations.domainModel

object myDomainModel

The @domainModel annotation scans the current package, recursively scanning any sub-packages, to gather your persistent objects and components.

For the non-annotation equivalent, you need to manually specify the package name:

package myPackage

import longevity.model.DomainModel

object myDomainModel extends DomainModel("myPackage")

The package scanning is a one-time cost and relatively cheap, but if you would prefer to avoid it, you can enumerate your PTypes and CTypes by hand, like so:

import longevity.model.DomainModel
import longevity.model.CTypePool
import longevity.model.PTypePool

object myDomainModel extends DomainModel(
  PTypePool(User, BlogPost, Blog),
prev: limitations on persistents, components, and key values
up: the domain model
next: the persistent type